Page 1 of 1
About Question enthuware.ocpjp.v7.2.1160 :
Posted: Thu Jan 14, 2016 3:55 pm
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
Re: About Question enthuware.ocpjp.v7.2.1160 :
Posted: Thu Jan 14, 2016 9:07 pm
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.
Re: About Question enthuware.ocpjp.v7.2.1160 :
Posted: Sun Jan 31, 2016 7:49 pm
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?
Re: About Question enthuware.ocpjp.v7.2.1160 :
Posted: Sun Jan 31, 2016 10:54 pm
by admin
That is correct.
Re: About Question enthuware.ocpjp.v7.2.1160 :
Posted: Mon May 15, 2017 8:35 pm
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)?
Re: About Question enthuware.ocpjp.v7.2.1160 :
Posted: Mon May 15, 2017 10:34 pm
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.
Re: About Question enthuware.ocpjp.v7.2.1160 :
Posted: Thu May 28, 2020 11:57 am
by saurabh.agarwal560
Why cant we call stmt.commit() as it can directly commit all the transactions?
Re: About Question enthuware.ocpjp.v7.2.1160 :
Posted: Thu May 28, 2020 12:41 pm
by admin
Because Statement doesn't have commit method. Connection does.