what happens if I do connection.setAutoCommit(false);
does it creates a new transaction at database side?
According to the documentation, connection.setAutoCommit(false)
will allow you to group multiple subsequent Statement
s under the same transaction. This transaction will be committed when connection.commit()
is invoked, as opposed to after each execute()
call on individual Statement
s (which happens if autocommit is enabled).
Changing the auto-commit mode through connection.setAutoCommit()
will implicitly commit the active transaction and create a new one. From the Javadocs:
NOTE: If this 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.