exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 71 discussion

Actual exam question from Oracle's 1z0-809
Question #: 71
Topic #: 1
[All 1z0-809 Questions]

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?

  • A. The Employee table is updated with the row: 112 Jack and the program prints: 112 Jerry
  • B. The Employee table is updated with the row: 112 Jack and the program prints: 112 Jack
  • C. The Employee table is not updated and the program prints: 112 Jerry
  • D. The program prints Exception is raised.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
JME_CHG
Highly Voted 3 years, 9 months ago
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...
upvoted 13 times
...
6c84cb9
Most Recent 4 months ago
Answer C C. "The Employee table is not updated and the program prints: 112 Jerry" True. Since rs.updateRow() was not called, the table will not be updated and the rs.absolute(2) method will position the cursor on the second row, which has the values ​​"112" and "Jerry".
upvoted 1 times
...
asdfjhfgjuaDCV
10 months, 2 weeks ago
c is the answer
upvoted 1 times
...
steefaand
11 months, 2 weeks ago
Selected Answer: C
C is correct since there is no call for updateRow.
upvoted 1 times
...
9641
3 years ago
Selected Answer: C
Because code is not call rs.updateRow();
upvoted 1 times
...
laura_lu93
3 years, 10 months ago
answer is A. second row is updated, but resultSet with SCROLL_INSENSITIVE can't see updated version.
upvoted 4 times
...
sansay61
4 years ago
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
upvoted 2 times
...
pul26
4 years, 1 month ago
Answer is B See https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago