Committing a unit of work
When using type 2 connectivity, your JDBC and SQLJ applications can issue JDBC and SQLJ commit and rollback method calls. The IBM Data Server Driver for JDBC and SQLJ converts these calls into a JCICS commit or a JCICS rollback call, resulting in a CICS® syncpoint being taken.
About this task
A JDBC or SQLJ commit results in the whole CICS unit of work being committed, not just the updates made to Db2®. CICS does not support committing work done using a JDBC connection independently of the rest of the CICS unit of work.
A JDBC or SQLJ application can also issue JCICS commit or rollback directly, and this has the same result as issuing a JDBC or SQLJ commit or rollback method call. The whole unit of work is committed or rolled back together, both Db2 updates and updates to CICS controlled resources.
- You have used the autocommit property of a JDBC connection.
- You have acquired the DriverManager connection using an explicit URL.
For a stand-alone application, these rules do not cause a problem, as CICS ensures that an end of task syncpoint is taken in addition to any syncpoint that is taken when the connection is closed. However, the JDBC and SQLJ application programming interfaces do not support the concept of multiple application programs for each unit of work. If you have a number of programs that make up an application, one program might access Db2, then call another program that also accesses Db2, in the course of a single unit of work. If you want these programs to be Java™ programs that use JDBC or SQLJ, you need to ensure that the unit of work is not committed when the connection to Db2 is closed, or else the application will not operate as planned. You should be particularly aware of this requirement if you are replacing programs in an existing application with Java programs that use JDBC or SQLJ, and you want to share the same CICS-Db2 thread between the programs. To address this issue, use a DriverManager with default URL or a DataSource connection.