- TYPE_FORWARD_ONLY
- TYPE_SCROLL_SENSITIVE
- TYPE_SCROLL_INSENSITIVE
Difference between INSENSITIVE and SENSITIVE
- An Insensitive resultset is like the snapshot of the data in the database when query was executed, A Sensitive resultset does not represent a snapshot of data rather it contains points to those rows which satisfy the query condition.
- After we get the resultset the changes made to data are not visible through the resultset and hence they are known as Insensitive, In Sensitive after we obtain the resultset if the data is modified then such modification are visible through resultset.
- Performance not affected with Insensitive, In Sensitive since a trip is made for every 'get' operation the performance drastically get affected.
How to change ResultSet type at the time of creating Statement or PreparedStatement object
- create Statement()
- create Statement(int type,int mode)
- prepareStatement(String set)
- prepareStatement(String SQL,int type, int mode)
INSENSITIVE
Statement st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = st.executeQuery("select * from emp");
SENSITIVE
Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = st.executeQuery("select * from emp");
TYPE_FORWARD_ONLY
Specifies that a ResultSet is not scroll-able that is rows within it can be advance only in the forward direction.
TYPE_SCROLL_INSENSITIVE
Specifies that a ResultSet is scroll-able in either direction. But in Insensitive to change committed by other transaction, other statement in the same direction.
TYPE_SCROLL_SENSITIVE
Specifies that a ResultSet is scroll-able in either direction and is affected by changes committed by other transaction or statement within the same transaction.
No comments:
Post a Comment