![]() |
|
By default, all new Connection objects are in autocommit mode: a COMMIT statement is automatically executed after each statement that is sent to the database server. To turn autocommit mode off for a connection, explicitly call the Connection.setAutoCommit(false) method.
When autocommit mode is off, Informix JDBC Driver implicitly starts a new transaction when the next statement is sent to the database server. This transaction lasts until the user issues a COMMIT or ROLLBACK statement. If the user has already started a transaction by executing setAutoCommit(false) and then calls setAutoCommit(false) again, the existing transaction continues unchanged. The Java program must explicitly terminate the transaction by issuing either a COMMIT or a ROLLBACK statement before it drops the connection to the database or the database server.
If the Java program sets autocommit mode on while inside a transaction, Informix JDBC Driver rolls back the current transaction before it actually turns autocommit mode on.
In a database that has been created with logging, if a COMMIT statement is sent to the database server (either with the Connection.commit() method or directly with an SQL statement) and autocommit mode is on, the error
-255 : Not in transaction is returned by the database server because there is currently no user transaction started.
In a database created in ANSI mode, explicitly sending a COMMIT statement to the database server commits an empty transaction. No error is returned because the database server automatically starts a transaction before it executes the statement if there is no user transaction currently open.