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

Given the records from the STUDENT table:

Given the code fragment:

Assume that the URL, username, and password are valid.

What is the result?

    Correct Answer: D

    In the given code fragment, the method moveToInsertRow() is used to move the cursor to the insert row. According to JDBC specifications, calling updateRow() while the cursor is on the insert row can throw a SQLException. Proper use for inserting a new row involves moving to the insert row, updating the columns, then calling insertRow(), not updateRow(). As the program attempts to use updateRow() on the insert row, it will throw an SQLException at runtime.

Discussion
JME_CHGOption: D

D because called refresh() before calling rs.insertRow() so updates in insert row lost (can someone confirm this please???) Also, if moveToInsertRow() removed, and called rs.updateRow() at the end, then answer would be C???

Svetleto13

Yes you are right.thats correct

DarGrinOption: D

D. SQL Exception due to rs.moveToInsertRow(); If we delete rs.moveToInsertRow(); the programm works fine

lchowenOption: D

Answer is D, because the correct way to insert a row is rs.insertRow(). Calling updateRow() at the insertion row throws SQL exception

xijxeyhoOption: C

movetoInsertRow() moves position to "next row when record can be inserted". So it looks that content is inserted after row "114". refresh() is called after updateRow(). It is ok inserted content is not lost. C in my opinion.

DmitryKOption: A

This method cannot be called when the cursor is on the insert row. for rs.moveToInsertRow(); Ok