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 column values from the first row using getString.
    while (rs.next()) {
        c1 = rs.getString(1);
        c2 = rs.getString(2);
        ...
    }
}
Members

All members of ResultSet, including all inherited members.


close method
getResultSetMetadata method
next method
previous method