JDBC Scrollable ResultSet Example

Whenever we create an object of ResultSet by default, it allows us to retrieve in forward direction only and we cannot perform any modifications on ResultSet object. Therefore, by default the ResultSet object is non-scrollable and non-updatable ResultSet.

In this tutorials, I am going to tell you how to make a ResultSet object as scrollable.

JDBC Scrollable ResultSet :

A scrollable ResultSet is one which allows us to retrieve the data in forward direction as well as backward direction but no updations are allowed. In order to make the non-scrollable ResultSet as scrollable ResultSet we must use the following createStatement() method which is present in Connection interface.

public Statement createStatement(int Type, int Mode);

Here type represents the type of scrollability and mode represents either read only or updatable. The
value of Type and the Modes are present in ResultSet interface as constant data members and they are:

public void afterLast (); It is used for making the ResultSet object to point to just after the last record.

public boolean isLast (); It returns true when rs is pointing to last record otherwise false.

public void last (); It is used to point the ResultSet object to last record.

public boolean isAfterLast (); It returns true when rs is pointing after last record otherwise false.

public void absolute (int); It is used for moving the ResultSet object to a particular record either in forward direction or in backward direction with respect to first record and last record respectively. If int value is positive, rs move in forward direction to that with respect to first record. If int value is negative, rs move in backward direction to that with respect to last record.

public void relative (int); It is used for moving rs to that record either in forward direction or in backward direction with respect to current record.

Hi
Folks,
you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,