Product Documentation

FairCom JDBC Developer's Guide

Previous Topic

Next Topic

Managing Transactions Explicitly to Improve Performance

By default, new connections in FairCom DB SQL JDBC applications are in autocommit mode.

In autocommit mode every FairCom DB SQL statement executes in its own transaction:

  • After successful completion, the JDBC Driver automatically commits the transaction.
  • If the statement execution fails, the JDBC Driver automatically rolls back the transaction.

Note: In autocommit mode, the JDBC Driver does not issue a commit after SELECT and CALL statements. The driver assumes these statements generate result sets and relies on the application to explicitly commit or roll back the transaction after it processes any result set and closes the statement.

You can change transaction mode to manual commit by calling the Connection.setAutoCommit() method. In manual commit mode, applications must commit a transaction by using the Connection.commit() method. Similarly, applications must explicitly roll back a transaction by invoking the Connection.rollback() method.

You will improve the performance of your programs by setting autocommit to false after creating a Connection object with the Connection.setAutoCommit() method:

Connection con = DriverManager.getConnection ( url, prop);

.

.

.

con.setAutoCommit(false);

TOCIndex