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?

Published on by javainterviewseries

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

t1-copy-13.png

  • The second argument is one of two ResultSet constants for specifying whether a result set is read-only or updatable

t2.png

 

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);

 

See the following video on various feature in Apache CXF .
 

 

Also visit our site from more such Java / J2EE/ Core Java interview question with answers videos.

To be informed of the latest articles, subscribe:
Comment on this post

java struts interview questions 06/02/2017 07:47

http://letusnotifyyou.com/java-struts-interview-questions/