Description should include the following:
- The SELECT statement is the standard way to select rows from a database and view them in a result set.
- A ResultSet object contains a table of data representing a database result set, which is generated by executing a statement that queries the database.
- The java.sql.ResultSet interface represents the result set of a database query.
- A ResultSet object maintains a cursor that points to the current row in the result set.
- The term result set refers to the row and column data contained in a ResultSet object.
- The methods of the ResultSet interface can be broken down into three categories:
- Navigational methods are used to move the cursor around.
- Get methods are used to view the data in the columns of the current row being pointed to by the cursor.
- Update methods are used to update the data in the columns of the current row. The updates can then be updated in the underlying database as well. The cursor is movable based on the properties of the ResultSet. These properties are designated when the corresponding statement that generated the ResultSet is created.
- JDBC provides following connection methods to create statements with desired ResultSet:
createStatement(int RSType, int RSConcurrency);
prepareStatement(String SQL, int RSType, int RSConcurrency);
prepareCall(String sql, int RSType, int RSConcurrency);
The first argument above indicates the type of ResultSet object, and the second argument is one of two ResultSet constants for specifying whether a result set is read-only or updatable.
- The possible ResultSet types include the following:
Type
|
Description
|
ResultSet.TYPE_FORWARD_ONLY
|
The cursor can only move forward in the result set.
|
ResultSet.TYPE_SCROLL_INSENSITIVE
|
The cursor can scroll forward and backward, and the result set is not sensitive to changes made by others to the database that occur after the result set was created.
|
ResultSet.TYPE_SCROLL_SENSITIVE
|
The cursor can scroll forward and backward, and the result set is sensitive to changes made by others to the database that occur after the result set was created.
|
If the ResultSet type is not specified, TYPE_FORWARD_ONLY will be automatically provided.