About Question enthuware.ocpjp.v8.2.1158 :

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

Moderator: admin

Post Reply
schchen2000
Posts: 106
Joined: Mon Mar 28, 2016 11:36 pm
Contact:

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

Post by schchen2000 »

admin wrote:No, there is no exception if you call rollback after a commit.
BTW, given that you've already called commit successfully, that means the connection is not in auto-commit mode.
I would again suggest you to go through the JavaDoc link that I gave above.
-Paul.
Oh, I did not know that. Thanks, Paul.

Schmichael

thodoris.bais
Posts: 25
Joined: Sat Jun 03, 2017 4:56 pm
Contact:

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

Post by thodoris.bais »

If the setAutoCommit method is called during a transaction and the auto-commit mode is changed, the transaction is committed. If setAutoCommit is called and the auto-commit mode is not changed, the call is a no-op.
I am not sure whether I fully understand this one. Could you please explain with a code example?

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

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

Post by admin »

1. lets say you make the auto commit mode false by calling con.setAutoCommit(false)
2. You start a firing querries and updates on the connection by calling con.executeUpdate(...)
3. Now, to commit the changes to the database, you should call con.commit(). But instead of calling commit, what if you call con.setAutoCommit(true)?
By calling con.setAutoCommit(true), you changed the status of auto commit from false to true. This will automatically cause the existing transaction to be committed. So there is no need to call con.commit() if you call con.setAutoCommit(true) in this case.
If you like our products and services, please help us by posting your review here.

thodoris.bais
Posts: 25
Joined: Sat Jun 03, 2017 4:56 pm
Contact:

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

Post by thodoris.bais »

Given that con.setAutoCommit(false); would have the same impact, shouldn't we change the question's format to accept both con.setAutoCommit(false); and con.setAutoCommit(true); as correct answers?

I see it a bit confusing now that one is forced to select one among the fore-mentioned two.

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

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

Post by admin »

No, con.setAutoCommit(false); will not have the same impact in this case. This is explained in detail in the explanation.
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 50 guests