Transaction isolation and locking considerations for JDBC and DB2 UDB for iSeries

The DB2 Universal Database (UDB) for iSeries documentation uses the terms activation groups and commitment definitions. If you are more familiar with JDBC or ODBC, you can equate these terms to JDBC-specific terms:

WAS terminology DB2 UDB for iSeries terminology
JDBC connection activation group
transaction commitment definition
transaction isolation levels commitment-control lock levels

This topic describes how transaction isolation levels and commitment-control lock levels relate to each other, and how your JDBC application makes use of the various levels.

Data locks

DB2 UDB for iSeries locks data in row units (records) with these types of locks:

DB2 UDB for iSeries can use both shared and exclusive locks in a multiple read-and-write situation.

Isolation levels

DB2 UDB for iSeries supports five isolation levels. For all isolation levels except No Commit, the database manager places exclusive locks on every row that is inserted, updated, or deleted. This ensures that any row changed during a transaction is not changed by any other transaction until after the modifications are committed.

For complete detailed descriptions of the various locks obtained while under a given transaction, refer to these DB2 UDB for iSeries documentation resources:

The following table briefly describes JDBC transaction isolation levels, CLI transaction isolation levels, and DB2 UDB for iSeries locking levels. It can be used as a reference when using iSeries commands or when using DB2 UDB for iSeries documentation.

Note: The table that follows does not include the No Commit isolation level, which does not use exclusive locks. Note also that enterprise beans do not support the No Commit isolation level.

For a JDBC connection that is running with automatic commit turned on (for example, through a call to Connection.setAutoCommit(true)), the types of locks acquired are the same as previously described. However, the locks are only held for the duration of the individual structured query language (SQL) operations.

When you access data with any transaction isolation level greater than No Commit, the table must be journaled. If the file being accessed is an SQL TABLE (physical file), then it is automatically journaled in the collection (library) in which it resides. However, explicitly journal a physical file that resides in a library. You can very loosely think of running a JDBC connection under either the NO_COMMIT or TRANSACTION_NONE isolation level as an optimization of auto-commit mode.