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.
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?
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.
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.