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

Given the code fragment:

Assume that:

The required database driver is configured in the classpath.

The appropriate database is accessible with the dbURL, userName, and passWord exists

The Employee table has a column ID of type integer and the SQL query matches one record.

What is the result?

    Correct Answer: D

    The code tries to print the employee ID directly from the ResultSet without moving the cursor to the first row. By default, the cursor is positioned before the first row when the ResultSet is created. To move the cursor to the first row, the rs.next() method should be called. Without this step, a SQLException will be thrown, leading to the catch block being executed and printing 'Error'.

Discussion
laura_lu93Option: D

Answer is D. ResultSet position is before firt line, we should use rs.next()

Svetleto13Option: D

D,tested

SigamaniOption: D

D is correct

steefaandOption: D

Answer is D. ResultSet is not moved to first row using next() method and SQLException is thrown which is caught and Error is printed.

iSnoverOption: D

Answer is D. ResultSet position is before firt line, we should use rs.next()

duydnOption: C

using rs.next() to move to the first record.

duydn

and I think the answer should be throw an exception(SQLException)

OhayouOption: D

Answer is D