ResultSet interface

Provides methods to traverse a table by row, and access the column data.

Syntax
public ResultSet
Base classes
Remarks

A ResultSet is generated by executing a PreparedStatement with a SQL SELECT statement using the execute or executeQuery methods.

The following example demonstrates how to execute a new PreparedStatement, fetch a row with the ResultSet, and access data from a specified column.

// Define a new SQL SELECT statement.
String sql_string = "SELECT column1, column2 FROM SampleTable";

// Create a new PreparedStatement from an existing connection.
PreparedStatement ps = conn.prepareStatement(sql_string);

// Create a new ResultSet to contain the query results of the SQL statement.
ResultSet rs = ps.executeQuery();

// Check if the PreparedStatement contains a ResultSet.
if (ps.hasResultSet()) {
    // Retrieve the column1 value from the first row using getString.
    String row1_col1 = rs.getString(1);
    // Get the next row in the table.
    if (rs.next) {
        // Retrieve the value of column1 from the second row.
        String row2_col1 = rs.getString(1);
    }
}
Members

All members of ResultSet, including all inherited members.


close function
getResultSetMetadata function
next function
previous function