Win a copy of Java Challengers this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

JDBC Question

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following question from https://www.examtopics.com/exams/oracle/1z0-809/view/30 :

Q149
Given the records from the STUDENT table:
sid      sname      semail
111    James       james@uni.com
112    Jane         jane@uni.com
114    John         john@uni.com

Given the code fragment:

Assume that the URL, username, and password are valid.
What is the result?

A. The STUDENT table is not updated and the program prints: 114 : John : john@uni.com
B. The STUDENT table is updated with the record: 113 : Jannet : jannet@uni.com
           and the program prints: 114 : John : john@uni.com
C. The STUDENT table is updated with the record: 113 : Jannet : jannet@uni.com
           and the program prints: 113 : Jannet : jannet@uni.com
D. A SQLException is thrown at run time.

Answer is D because rs.updateRow()/rs.refreshRow() cannot be called on the insert row...

But I was wondering what would happen if we replaced
rs.updateRow();
rs.refreshRow();
for
rs.insertRow();

?

1.
would C be correct?

OR

2.
would it still be an SQLException because we are in TYPE_SCROLL_INSENSITIVE mode?

Can someone confirm whether 1. or 2. is correct or maybe a totally different answer? :/
 
Jay Chung
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just figured it out, the answer will be 1.

i.e. updateRow()/refreshRow() changes will be visible because TYPE_ SCROLL_INSENSITIVE is about the changes made to the db by other means, if you change the same ResultSet, then you will see new values...
reply
    Bookmark Topic Watch Topic
  • New Topic