Java Reference
In-Depth Information
The method absolute(int rowNumber) moves the cursor to the row number indicated
in the argument. If the number is positive, the cursor moves to the given row number
from the beginning. If the number is negative, the cursor moves to the given row
number from the end.
Row numbers count from 1, so calling absolute(1)puts the cursor on the
first row, and calling absolute(-1) puts the cursor on the last row.
Note
The method relative(int rowNumber) lets you specify how many rows to move from
the current row and in which direction to move. A positive number moves the cursor
forward the given number of rows; a negative number moves the cursor backward the
given number of rows.
Getting the Cursor Position
In addition to positioning the cursor, you can get its position by using one of these
methods:
 
isFirst()
 
isLast()
 
isBeforeFirst()
 
isAfterLast()
 
getRow()
Again, the behavior of these methods is apparent from their names.
Note The method isAfterLast() returns false when the cursor is not after the last
row and when the result set is empty, so a retur ned value of false from the
method isAfterLast() cannot be used to indicate that data is available.
Updatable ResultSets
An UpdatableResultSet is, as the name suggests, updatable. You can make updates
to the values in the ResultSet itself, and these changes are reflected in the database.
To create an UpdatableResultSet object, you need to call the createStatement
method with the ResultSet constant CONCUR_UPDATABLE as the second
argument. The Statement object created produces an updatable ResultSet object
when it executes a query.
An updatable ResultSet object does not necessarily have to be scrollable.
Note
Once you have an UpdatableResultSet object, you can insert a new row, delete an
existing row, or modify one or more column values.
Search WWH ::




Custom Search