1z0-809 Exam QuestionsBrowse all questions from this exam

1z0-809 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?

Show Answer
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

5 comments
Sign in to comment
JME_CHGOption: D
Mar 5, 2021

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
May 21, 2021

Yes you are right.thats correct

DmitryKOption: A
Mar 13, 2021

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

xijxeyhoOption: C
Apr 20, 2021

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.

lchowenOption: D
Sep 21, 2022

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

DarGrinOption: D
Jun 2, 2024

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