About Question enthuware.ocpjp.v8.2.1911 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
jme_chg
Posts: 29
Joined: Sun Feb 07, 2021 6:30 pm
Contact:

About Question enthuware.ocpjp.v8.2.1911 :

Post by jme_chg »

Just wanted to confirm, if we wanted to see the updates, then we could make 1 of the following modifications:

1. rs1.refreshRow() before printing

OR

2. change mode to TYPE_SCROLL_SENSITIVE (for stmt1)

OR

3.
declare
ResultSet rs1 = stmt1.executeQuery(query);
AFTER
rs2.updateRow();
(don't need stmt1 after rs2.updateRow() as the static view of the database is at the time of query)

Can someone confirm if my understanding is correct please?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by admin »

That is correct.
If you like our products and services, please help us by posting your review here.

jme_chg
Posts: 29
Joined: Sun Feb 07, 2021 6:30 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by jme_chg »

if //2
was using rs2.getString("zip"), then would answer have been B?

or would you need to call rs2.refreshRow() after //1 for it to be visible?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by admin »

Yes, in that case answer would be B.
If you like our products and services, please help us by posting your review here.

jme_chg
Posts: 29
Joined: Sun Feb 07, 2021 6:30 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by jme_chg »

admin wrote:
Wed Apr 14, 2021 2:17 am
Yes, in that case answer would be B.
But doesn't this go against what it means to be TYPE_SCROLL_INSENSITIVE?

or are rs.updateRow()/rs.insertRow() the only exceptions whereby calling these also updates the ResultSet?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by admin »

No, insensitive is about the changes made to the db by other means. If you change the same resultset then you will see new values.

You may run a simple test program to check it out and/or go through the API JavaDoc: https://docs.oracle.com/en/java/javase/ ... ction.html
If you like our products and services, please help us by posting your review here.

jme_chg
Posts: 29
Joined: Sun Feb 07, 2021 6:30 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by jme_chg »

admin wrote:
Wed Apr 14, 2021 4:12 am
No, insensitive is about the changes made to the db by other means. If you change the same resultset then you will see new values.

You may run a simple test program to check it out and/or go through the API JavaDoc: https://docs.oracle.com/en/java/javase/ ... ction.html
Ah that would makes sense, thank you!!! :joy:

jme_chg
Posts: 29
Joined: Sun Feb 07, 2021 6:30 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by jme_chg »

admin wrote:
Wed Apr 14, 2021 4:12 am
No, insensitive is about the changes made to the db by other means. If you change the same resultset then you will see new values.

You may run a simple test program to check it out and/or go through the API JavaDoc: https://docs.oracle.com/en/java/javase/ ... ction.html
Just looking at Q71 here: https://www.examtopics.com/exams/oracle ... 9/view/15/

Answer is C but that would then go against what you have just said...

When I looked at this Q71 and read your explanation I thought the answer would therefore be:

The Employee table is not updated and the program prints: 112 Jack

because updateString(2) updates the same ResultSet, but updateRow() has not been called, so the database is not updated.
But this is not an option at all.

have I misunderstood something? D:

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by admin »

Unless updateRow is called the database will not be updated. That's pretty clear from the documentation: https://docs.oracle.com/en/java/javase/ ... ltSet.html

To see the changes made to the database by other processes/other resultsets in your ResultSet, you need to invoke refreshRow, that is also clear.

So, I am not sure what is the confusion?
If you like our products and services, please help us by posting your review here.

jme_chg
Posts: 29
Joined: Sun Feb 07, 2021 6:30 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by jme_chg »

admin wrote:
Wed Apr 21, 2021 10:52 pm
Unless updateRow is called the database will not be updated. That's pretty clear from the documentation: https://docs.oracle.com/en/java/javase/ ... ltSet.html

To see the changes made to the database by other processes/other resultsets in your ResultSet, you need to invoke refreshRow, that is also clear.

So, I am not sure what is the confusion?
My understanding was that

-rs.updateXXX(colName, newValue) //update columns IN ResultSet
-Call rs.updateRow(); //to update IN db with (ResultSet updates commited to db…)

But I'm guessing it should be:

-rs.updateXXX(colName, newValue) //update columns but not commit changes to either ResultSet or db
-Call rs.updateRow(); //to update IN ResultSet AND db

can you confirm this is now 100% correct? (because I keep doubting myself D:)

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by admin »

NO!!!
My understanding was that

-rs.updateXXX(colName, newValue) //update columns IN ResultSet
-Call rs.updateRow(); //to update IN db with (ResultSet updates commited to db…)
This is correct and that is what I wrote before as well (twice). Please see my responses above. Specifically:
If you change the same resultset then you will see new values.

You may run a simple test program to check it out and/or go through the API JavaDoc: https://docs.oracle.com/en/java/javase/ ... ction.html
I am not sure what the other question provider says or means. You need to ask them about it.
If you like our products and services, please help us by posting your review here.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by admin »

As I mentioned earlier, you need to go through the documentation at: https://docs.oracle.com/en/java/javase/ ... ltSet.html

The example given there clearly says:
The following code fragment updates the NAME column in the fifth row of the ResultSet object rs and then uses the method updateRow to update the data source table from which rs was derived.

rs.absolute(5); // moves the cursor to the fifth row of rs
rs.updateString("NAME", "AINSWORTH"); // updates the
// NAME column of row 5 to be AINSWORTH
rs.updateRow(); // updates the row in the data source
If you like our products and services, please help us by posting your review here.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1911 :

Post by admin »

Or just write a test program and check it out!
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 62 guests