About Question enthuware.ocpjp.v7.2.1160 :

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

Moderator: admin

Post Reply
sir_Anduin@yahoo.de
Posts: 62
Joined: Fri Aug 07, 2015 2:16 pm
Contact:

About Question enthuware.ocpjp.v7.2.1160 :

Post by sir_Anduin@yahoo.de »

hi,

what exactly means "during a transaction"
Another way is to utilize the side effect of changing the auto-commit mode of the connection. 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. In this question, con.setAutoCommit(true) changes the auto-commit mode of the connection from false to true and therefore this call commits the changes.
Thanks

Aleks

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

Re: About Question enthuware.ocpjp.v7.2.1160 :

Post by admin »

That means anywhere between the point where a transaction is started and the point where the transaction is committed/rolled back.

HTH,
Paul.

krohani
Posts: 31
Joined: Tue Oct 06, 2015 1:57 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1160 :

Post by krohani »

So just to clarify, is setAutoCommit is called and only if it changes the commit mode does the transaction commit, correct?

So doing a con.setAutoCommit(false) at the beginning and again at the end of a block of code which has several db statmenet executeUpdate calls would mean that those statements did not get commited by that second autoCommit statement?

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

Re: About Question enthuware.ocpjp.v7.2.1160 :

Post by admin »

That is correct.

lenalena
Posts: 56
Joined: Tue Feb 21, 2017 4:24 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1160 :

Post by lenalena »

Might be obvious, but I just want to confirm... If you call setAutoCommit(false) and it changes the status from true to false - does it also commit all previous transactions (and autoCommit is disabled only going forward)?

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

Re: About Question enthuware.ocpjp.v7.2.1160 :

Post by admin »

Well, if the auto commit is being changed from true to false, there cannot be a preexiting previous transaction because every statement is executed and committed immediately when auto commit is true. So what do you think would be left to commit?

HTH,
Paul.

saurabh.agarwal560
Posts: 11
Joined: Thu May 28, 2020 9:53 am
Contact:

Re: About Question enthuware.ocpjp.v7.2.1160 :

Post by saurabh.agarwal560 »

Why cant we call stmt.commit() as it can directly commit all the transactions?

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

Re: About Question enthuware.ocpjp.v7.2.1160 :

Post by admin »

Because Statement doesn't have commit method. Connection does.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 11 guests