Auto-configuring a Db2 DataSource with type 2 connectivity

Create a CICS®-aware Db2® DataSource with type 2 connectivity by using the com.ibm.cics.jvmserver.wlp.jdbc.driver.location property.

Before you begin

Ensure your CICS region has access to the IBM® Data Server Driver for JDBC and SQLJ for Db2 and a CICS Db2 connection (DB2CONN) is defined. For more information, see Configuring a JVM server to support DB2.

6.1 com.ibm.cics.jvmserver.wlp.autoconfigure must also be set to true if you want auto configure to add a dataSource element or a cicsts_dataSource element to server.xml.

About this task

CICS creates a Db2 DataSource with type 2 connectivity in the Liberty server.xml, which operates through the CICS DB2CONN, by using the JVM profile com.ibm.cics.jvmserver.wlp.jdbc.driver.location property.

The JNDI name of the DataSource is jdbc/defaultCICSDataSource.

Setting the com.ibm.cics.jvmserver.wlp.jdbc.driver.location property creates a Db2 dataSource element or a cicsts_dataSource element, dependent on which features are installed. The id attribute of the created element is set to defaultCICSDataSource in server.xml.

Table 1. Auto-configured data source type
JDBC feature installed DataSource configuration type Notes
cicsts:jdbc-1.0 cicsts_dataSource  
jdbc-4.0, jdbc-4.1, jdbc-4.2, or jdbc-4.3 dataSource  
No JDBC feature dataSource The jdbc-4.2 feature is installed as a default. For more information, see CICS Liberty defaulted settings

For more information about configuring the IBM Data Server Driver for JDBC and SQLJ for Db2 with type 2 connectivity, see Manually configuring Db2 JDBC type 2 connectivity with the Liberty JDBC features and Manually configuring Db2 type 2 connectivity with the CICS JDBC feature.

To use DriverManager in your applications, you need to configure the IBM Data Server Driver for JDBC and SQLJ for Db2 manually.

Procedure

  1. Set the com.ibm.cics.jvmserver.wlp.jdbc.driver.location in the JVM profile to the location of the Db2 JDBC library.
    For example,
    -Dcom.ibm.cics.jvmserver.wlp.jdbc.driver.location=/usr/lpp/db2v13/jdbc
  2. Optional: Set the Db2 schema. For more information, see Setting the Db2 schema in a JVM server
  3. Optional: Install a JDBC feature. If no JDBC feature is installed, CICS installs the jdbc-4.2 feature.
    • To use a Liberty JDBC feature, install one of the jdbc-4.0, jdbc-4.1, jdbc-4.2, or jdbc-4.3 features.
    • To use the CICS JDBC feature, install the cicsts:jdbc-1.0 feature.
    Example configuration to install the JDBC 4.2 feature.
    <featureManager>
        <feature>jdbc-4.2</feature>
    </featureManager>
  4. Install and enable the JVMSERVER resource.

Results

A Db2 data source with type 2 connectivity is added to the Liberty server configuration file server.xml.

CICS auto-configures a library element and a data source element in server.xml. The library targets the location that is specified by com.ibm.cics.jvmserver.wlp.jdbc.driver.location. The data source element depends on the features that are installed in Liberty.

Example

Auto-configured elements added to server.xml when com.ibm.cics.jvmserver.wlp.jdbc.driver.location is set to /usr/lpp/db2v13/jdbc, for a DataSource with type 2 connectivity.

When a Liberty JDBC feature is installed:
<dataSource id="defaultCICSDataSource" jndiName="jdbc/defaultCICSDataSource" transactional="false">
    <jdbcDriver libraryRef="defaultCICSDb2Library"/>
    <properties.db2.jcc driverType="2"/>
    <connectionManager agedTimeout="0"/>
</dataSource>

<library id="defaultCICSDb2Library">
    <fileset dir="/usr/lpp/db2v13/jdbc/classes" includes="db2jcc4.jar db2jcc_license_cisuz.jar"/>
    <fileset dir="/usr/lpp/db2v13/jdbc/lib" includes="libdb2jcct2zos4_64.so"/>
</library>
When the CICS JDBC feature is installed:
<cicsts_dataSource id="defaultCICSDataSource" jndiName="jdbc/defaultCICSDataSource" transactional="false" />

<cicsts_jdbcDriver id="defaultCICSJdbcDriver" libraryRef="defaultCICSDb2Library"/>

<library id="defaultCICSDb2Library">
    <fileset dir="/usr/lpp/db2v13/jdbc/classes" includes="db2jcc4.jar db2jcc_license_cisuz.jar"/>
    <fileset dir="/usr/lpp/db2v13/jdbc/lib" includes="libdb2jcct2zos4_64.so"/>
</library>