The ResultSet interface in JDBC is used to store and retrieve the data returned by a SQL query. It represents the rows and columns of the result produced by a SELECT statement. A ResultSet maintains a cursor that points to the current row, and methods such as next(), previous(), first(), and last() are used to move the cursor between rows. Data can be retrieved from columns using methods such as getInt(), getString(), getDouble(), and getDate(). It also provides methods to check for NULL values, determine the current row, and close the result set after use.
Methods of ResultSet:
| Method Signature and Short Description |
|---|
|
Moves the cursor to the next row of the result set. |
|
Moves the cursor to the previous row of the result set. |
|
Moves the cursor to the first row of the result set. |
|
Moves the cursor to the last row of the result set. |
|
Moves the cursor to the specified row number. |
|
Moves the cursor a specified number of rows forward or backward. |
|
Retrieves the value of the specified column as an integer. |
|
Retrieves the value of the specified column as a String. |
|
Retrieves the value of the specified column as a double. |
|
Retrieves the value of the specified column as a float. |
|
Retrieves the value of the specified column as a boolean. |
|
Retrieves the value of the specified column as a SQL date. |
|
Retrieves the value of the specified column using its column name. |
|
Retrieves the value of the specified column as an integer using its column name. |
|
Checks whether the last retrieved column value was SQL |
|
Releases the resources associated with the |
|
Checks whether the |
|
Returns the current row number of the cursor. |
