JAVA / J2EE interview question - Explain types of resultsets and show difference between TYPE_SCROLL_INSENSITIVE and TYPE_SCROLL_SENSITIVE and How to Make Updates to Updatable Result Sets?
Types of resultsets
- TYPE_FORWARD_ONLY
- TYPE_SCROLL_INSENSITIVE and
- TYPE_SCROLL_SENSITIVE
How can move the cursor in scrollable result sets?
Two arguments are generally passed for scrollable result sets
- The first argument indicates the type of ResultSet
- The second argument is one of two ResultSet constants for specifying whether a result set is read-only or updatable
Difference between TYPE_SCROLL_INSENSITIVE and TYPE_SCROLL_SENSITIVE.
- Difference between the two has to do with whether a result set reflects changes that are made to it while it is open and whether certain methods can be called to detect these changes
- ResultSet of type TYPE_SCROLL_INSENSITIVE does not reflect changes made while it is still open
- ResultSet of type TYPE_SCROLL_SENSITIVE does reflect changes made while it is still open
Make Updates to Updatable Result Sets.
In JDBC 2 rows can be directly updated in resultset and the same will be reflected in database. To do the same we use updatable resultset which is done by
passingResultSet.CONCUR_UPDATABLE to the createStatement()
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
Also visit our site from more such Java / J2EE/ Core Java interview question with answers videos.