[AIX Solaris HP-UX Linux Windows][z/OS]

Sharing locks between transaction branches

You can specify that multiple application components on different application servers can share access to data in a single DB2® database under the same global transaction. You specify that the different transaction branches share locks under the global transaction.

To do this, you set the branch coupling attribute on the resource references for the shared DB2 connections in the application.

Note: Lock sharing in WebSphere® Application Server Version 8 is only supported on DB2; setting lock sharing on a resource reference for a non-DB2 database will result in an exception.

Usually, application components can share locks only when those application components are collocated on the same server.

Sharing locks between transaction branches means that multiple DB2 Java™ Database Connectivity (JDBC) connections to the same database that are in the same transaction, from the same or different servers, can share locks when accessing data. In this way, multiple components can access the data without causing timeouts or other unwanted situations.

Sharing locks between transaction branches provides the benefit that two Enterprise JavaBeans (EJBs) on two servers can share the visibility of data, and the locks to that data, within a distributed transaction. Therefore, shared access to data does not depend on the location of the application component.

To specify that transaction branches share locks, you set the branch coupling attribute on the DB2 resource reference of the application to a value of tight. For example:
<resource-ref name="jdbc/DataSource_LockSharing" branch-coupling="TIGHT"/>
If you do not specify a branch coupling value, the default value of loose is used, that is, transaction branches do not share locks.

You can set the branch coupling attribute on the DB2 resource reference of the application by using Rational® Application Developer tools. For detailed information, see the Rational Application Developer information center. The application component must have a deployment descriptor; you cannot specify this attribute if annotation has been used.

To share locks between transaction branches in this way, the following conditions apply:
  • The database must be DB2 on a distributed or z/OS® operating system.
  • The JDBC provider must be DB2 Using IBM® JCC Driver Version 3.51 and later, Version 3.6 and later, or Version 4.1 and later.
  • Connections must use JDBC type 4 connectivity to one of the following:
    • DB2 Universal Database (DB2 UDB) Version 8 and later
    • DB2 UDB for z/OS Version 8 with program temporary fix (PTF) UK27815 and later
    • DB2 UDB for z/OS Version 9.1 with Fix Pack 4 and later
    • DB2 UDB for z/OS Version 9.5 and later
Note: An IBM Support Technote is available that provides a complete list of which DB2 versions support lock sharing. Search the IBM Support Portal for relevant information.