Java Reference
In-Depth Information
the result set. If the result is marked as sensitive, changes to the database
should appear in the result set as well.
There are several methods in the ResultSet interface that involve moving the
cursor, including:
public void beforeFirst() throws SQLException.
Moves the cursor to
just before the first row.
public void afterLast() throws SQLException.
Moves the cursor to just
after the last row.
p ublic boolean first() throws SQLException.
Moves the cursor to the
first row.
public void last() throws SQLException. Moves the cursor to the last row.
public boolean absolute(int row) throws SQLException.
Moves the cur-
sor to the specified row.
public boolean relative(int row) throws SQLException. Moves the cur-
sor the given number of rows forward or backwards from where it cur-
rently is pointing.
public boolean previous() throws SQLException. Moves the cursor to
the previous row. This method returns false if the previous row is off the
result set.
public boolean next() throws SQLException. Moves the cursor to the
next row. This method returns false if there are no more rows in the
result set.
public int getRow() throws SQLException.
Returns the row number that
the cursor is pointing to.
public void moveToInsertRow() throws SQLException. Moves the cur-
sor to a special row in the result set that can be used to insert a new row
into the database. The current cursor location is remembered.
public void moveToCurrentRow() throws SQLException. Moves the
cursor back to the current row if the cursor is currently at the insert row;
otherwise, this method does nothing.
Viewing a Result Set
The ResultSet interface contains dozens of methods for getting the data of the
current row. There is a get method for each of the possible data types, and each
get method has two versions: one that takes in a column name, and one that
takes in a column index.
Search WWH ::




Custom Search