Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

JDBC Interview Questions and Answers

Question: What’s the difference between TYPE_SCROLL_INSENSITIVE , and TYPE_SCROLL_SENSITIVE?
Answer: You will get a scrollable ResultSet object if you specify one of these ResultSet constants.The 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. Generally speaking, 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. All three types of result sets will make changes visible if they are closed and then reopened:
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet srs =
stmt.executeQuery("SELECT EMP_NAME, SAL FROM EMPLOYEE");
srs.afterLast();
while (srs.previous())
{
String name = srs.getString("EMP_NAME");
float sal = srs.getFloat("SAL");
System.out.println(name + " " + sal);
}
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook