Page 1 of 1

About Question enthuware.ocpjp.v8.2.1911 :

Posted: Thu Mar 18, 2021 4:15 pm
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?

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

Posted: Thu Mar 18, 2021 11:10 pm
by admin
That is correct.

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

Posted: Wed Apr 14, 2021 1:02 am
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?

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

Posted: Wed Apr 14, 2021 2:17 am
by admin
Yes, in that case answer would be B.

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

Posted: Wed Apr 14, 2021 3:51 am
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?

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

Posted: Wed Apr 14, 2021 4:12 am
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

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

Posted: Wed Apr 14, 2021 4:30 am
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:

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

Posted: Wed Apr 21, 2021 3:53 pm
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:

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

Posted: Wed Apr 21, 2021 10:52 pm
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?

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

Posted: Wed Apr 21, 2021 11:52 pm
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:)

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

Posted: Thu Apr 22, 2021 1:30 am
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.

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

Posted: Thu Apr 22, 2021 1:42 am
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

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

Posted: Thu Apr 22, 2021 1:42 am
by admin
Or just write a test program and check it out!