What is difference between TYPE_SCROLL_INSENSITIVE and TYPE_SCROLL_SENSITIVE ResultSet type in java




In this tutorial we will learn What are differences and similarities between TYPE_SCROLL_INSENSITIVE and TYPE_SCROLL_SENSITIVE ResultSet type in java

What is difference between TYPE_SCROLL_INSENSITIVE and TYPE_SCROLL_SENSITIVE ResultSet type in java?
TYPE_SCROLL_INSENSITIVE
TYPE_SCROLL_SENSITIVE
TYPE_SCROLL_INSENSITIVE is not sensitive to the changes made to the data that underlies the ResultSet. (It means that if some thread modifies the data in the database which ResultSet currently holds won’t impact/change the already opened ResultSet’s data).
TYPE_SCROLL_SENSITIVE is sensitive to the changes made to the data that underlies the ResultSet. (It means that if some thread modifies the data in the database which ResultSet currently holds will impact/change the already opened ResultSet’s data).
getType() - method returns ResultSet object type. It returns 1004 if ResultSet object type is TYPE_SCROLL_INSENSITIVE.

In ResultSet interface  TYPE_SCROLL_INSENSITIVE = 1004
getType() - method returns ResultSet object type. It returns 1005 if ResultSet object type is TYPE_SCROLL_SENSITIVE.

In ResultSet interface  TYPE_SCROLL_SENSITIVE = 1005;

Example -
Let’ say you have multiple users in the database.

You issued select query at 1:00

Than some other user updated the underlying database at 1:01

With TYPE_SCROLL_INSENSITIVE ResultSet, at 1:02 you will still be scrolling (using next(), previous(), first(), last(), absolute() and relative() methods) at old data fetched the at 1:00 and not the updated one.

Example -
Let’ say you have multiple users in the database.

You issued select query at 1:00

Than some other user updated the underlying database at 1:01

With TYPE_SCROLL_SENSITIVE ResultSet, at 1:02 you will be scrolling (using next(), previous(), first(), last(), absolute() and relative() methods) at fresh data updated at 1:01 and not the old one.


So far we learned What are differences between TYPE_SCROLL_INSENSITIVE and TYPE_SCROLL_SENSITIVE ResultSet type in java

What are similarities between TYPE_SCROLL_INSENSITIVE and TYPE_SCROLL_SENSITIVE ResultSet type in java?
TYPE_SCROLL_INSENSITIVE
TYPE_SCROLL_SENSITIVE
In TYPE_SCROLL_INSENSITIVE cursor can move (scroll) both forward and backward.
In TYPE_SCROLL_SENSITIVE cursor can move (scroll) both forward and backward.
Cursor can be moved to absolute/specific/relative position as well
Cursor can be moved to absolute/specific/relative position as well

So, in this tutorial we learned what are differences and similarities between TYPE_SCROLL_INSENSITIVE and TYPE_SCROLL_SENSITIVE ResultSet type in java.

No comments:

Post a Comment