ResultSet navigation
In this chapter you will learn:
Navigating a Result Set
We can use the following methods in the ResultSet interface to move the cursor.
public void beforeFirst()
Moves the cursor to just before the first rowpublic void afterLast()
Moves the cursor to just after the last rowpublic boolean first()
Moves the cursor to the first rowpublic void last()
Moves the cursor to the last row.public boolean absolute(int row)
Moves the cursor to the specified rowpublic boolean relative(int row)
Moves the cursor for given number of rows forward or backwards relative to its current position.public boolean previous()
Moves the cursor to the previous row. It returns false if the current row is the first row in the result setpublic boolean next()
Moves the cursor to the next row. It returns false if current row is the last row in the result setpublic int getRow()
Returns the row number that the cursor is pointing to.public void moveToInsertRow()
Moves the cursor 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()
Moves the cursor back to the current row if the cursor is currently at the insert row; otherwise, this method does nothing
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » Statements, ResultSet, Exception, Warning