Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 71

Given the records from the Employee table:

and given the code fragment: try {

Connection conn = DriverManager.getConnection (URL, userName, passWord);

Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

ResultSet.CONCUR_UPDATABLE);

st.execute("SELECT*FROM Employee");

ResultSet rs = st.getResultSet();

while (rs.next()) {

if (rs.getInt(1) ==112) {

rs.updateString(2, "Jack");

}

}

rs.absolute(2);

System.out.println(rs.getInt(1) + " " + rs.getString(2));

} catch (SQLException ex) {

System.out.println("Exception is raised");

}

Assume that:

The required database driver is configured in the classpath.

The appropriate database accessible with the URL, userName, and passWord exists.

What is the result?

    Correct Answer: C

    The Employee table is not updated because the method rs.updateRow() is not called after rs.updateString(2, 'Jack'). Hence, the ResultSet changes are not committed to the database. Consequently, the program will print the original row, which is 112 Jerry.

Discussion
JME_CHGOption: C

Answer is C!!! it's INSENSITIVE, BUT this means it cannot see changes to db made my other means... if you change the same ResultSet, you can see it even in INSENSITIVE mode! But table is not updated because rs.updateRow() needs to be called for ResultSet updates to be committed to the db...

laura_lu93Option: A

answer is A. second row is updated, but resultSet with SCROLL_INSENSITIVE can't see updated version.

sansay61Option: C

when statement is executed resultset position is beforefirst. then next is called, cursor points to 111 id which doesnt satisfy condition, so the row wouldnt be updated. Then cursor goes to second row and prints it. So c is the right answer

asdfjhfgjuaDCVOption: C

c is the answer

steefaandOption: C

C is correct since there is no call for updateRow.

9641Option: C

Because code is not call rs.updateRow();

pul26Option: B

Answer is B See https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html