Setting the transaction timeout value for an XAResource instance
Use the XAResource.setTransactionTimeout method to reduce occurrences of deadlocks in a Db2® database that is the target of distributed transactions.
About this task
A distributed transaction to Db2 on Linux®, UNIX, and Windows systems that ends, but cannot be prepared, is not an indoubt transaction. Therefore, the transaction manager cannot recover the transaction, and the Db2 resource manager does not put the transaction in its list of indoubt transactions. The Db2 resource manager does not roll back the transaction immediately, but waits until all connections to the database are released. During this period of inactivity, the transaction continues to hold locks on the database. If the transaction manager does not disconnect all connections to the database to allow rollback, the ended transaction continues to lock database records. If another application attempts to access those locked records, a deadlock can occur.
In a Java™ application that uses distributed transactions and IBM® Data Server Driver for JDBC and SQLJ type 4 connectivity, you can prevent a transaction from holding locks on a database indefinitely by calling the XAResource.setTransactionTimeout method to set a timeout value on transactions.
Procedure
To set the transaction timeout value for an XAResource instance: