JDBC and SQLJ connections

When using the IBM® Data Server Driver for JDBC and SQLJ in CICS® Java™ applications, the following information should be considered.

Using the IBM Data Server Driver for JDBC and SQLJ with type 2 connectivity

If you are using type 2 connectivity, a Java application for CICS can only have one JDBC connection or one SQLJ connection open at once.

Although JDBC allows an application to have multiple connections at the same time, use of type 2 connectivity restricts this to one. However, an application can close an existing connection and open a connection to a new DB2® location, if required.

As a guideline, an application that has an open connection should close the connection before linking to another application that might use JDBC or SQLJ. For Java programs that are part of an application suite, you need to consider the implications of closing the connection, because if you are using an explicit URL, closing the connection can cause a syncpoint to be taken. If you are using a default URL, a syncpoint does not have to be taken when the connection is closed.

See Committing a unit of work for more information about type 2 connectivity.

Using the IBM Data Server Driver for JDBC and SQLJ with type 4 connectivity (Liberty JVM server only)

If you are using type 4 connectivity, a Java application for CICS can have multiple JDBC connections or multiple SQLJ connections open at once. Care should be taken to maintain data integrity, it is advisable to use the Java Transaction API to clearly demarcate transaction boundaries.

Note:

The JDBC 4.0 and the JDBC 4.1 implementations reside in the same driver.

When you use the jdbc-4.1 feature, the RowSetFactory interface and RowSetProvider class attempt to create a new JDBC connection.