Your Ad Here

Friday, June 25, 2010

Difference between ResultSet TYPE_SCROLL_SENSITIVE and TYPE_SCROLL_INSENSITIVE

Difference between ResultSet TYPE_SCROLL_SENSITIVE and TYPE_SCROLL_INSENSITIVE

If you would like to have a scrollable ResultSet Object then you need to supply constant when you create an object of it. By default it is FORWARD_ONLY, you can traverse forward in order to fetch records from table.

e.g. Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE , ResultSet.CONCUR_READ_ONLY);
Or
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE , ResultSet.CONCUR_READ_ONLY);

Or
Statement stmt = this.con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

Or
Statement stmt = this.con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);


A result set that is TYPE_SCROLL_INSENSITIVE does not reflect changes made while it is still open and one that is TYPE_SCROLL_SENSITIVE does.
Changes will be visible if result set is closed and re-opened.

TYPE_SCROLL_SENSTIVE does not *guarantee* that all changes made to the result set by others will be visible.It depends on a number of factors including the driver implementation (whether it caches the rows or not), the transaction isolation level etc...

No comments:

Post a Comment