Controlling Autocommit
Controlling Autocommit#
The autocommit mode of a session can be set with the auto_commit connection attribute or the setAutoCommit method of the JDBC Connection object for Altibase JDBC applications. If autocommit is enabled with auto_commit=true or the setAutoCommit(true) method, the Altibase server automatically commits transactions.
Autocommit can also be enabled with the clientside_auto_commit connection attribute. If clientside_auto_commit is set to on, instead of the Altibase server, the JDBC driver automatically commits transactions.
When clientside_auto_commit is set to off, the autocommit mode of a session is determined by the setAutoCommit method.
To disable autocommit for a session, call setAutoCommit(false).
Calling setAutoCommit(false) on a client_auto_commit=on session disables autocommit and calling setAutoCommit(true) thereafter restores the session to the autocommit mode of the JDBC driver.
When autocommit is disabled, the user must manually commit or rollback with the commit() or rollback() method.
The following table sums up the above.
Autocommit Mode | How to set |
---|---|
Server automatically commits transactions | auto_commit=true or setAutoCommit(true) or omitted |
JDBC driver automatically commits transactions | auto_commit=true(or omitted) and clientside_auto_commit=on |
Autocommit is disabled | auto_commit=false or setAutoCommit(false) |