Updated on 2024-05-14 GMT+08:00

JDBC API Reference

Obtaining Data from a Result Set

ResultSet objects provide a variety of methods to obtain data from a result set. Table 1 lists the common methods for obtaining data. If you want to know more about other methods, see JDK official documents.

Table 1 Common methods for obtaining data from a result set

Method

Description

Difference

int getInt(int columnIndex)

Obtains int data by column index.

-

int getInt(String columnLabel)

Obtains int data by column name.

-

String getString(int columnIndex)

Obtains string data by column index.

If the column type is integer and the column contains the ZEROFILL attribute, GaussDB pads 0s to meet the width required by the ZEROFILL attribute and outputs the result. MySQL directly outputs the result.

String getString(String columnLabel)

Obtains string data by column name.

If the column type is integer and the column contains the ZEROFILL attribute, GaussDB pads 0s to meet the width required by the ZEROFILL attribute and outputs the result. MySQL directly outputs the result.

Date getDate(int columnIndex)

Obtains date data by column index.

-

Date getDate(String columnLabel)

Obtains date data by column name.

-