Manually configuring a CICS DB2 DataSource or the DriverManager interface with JDBC type 2 connectivity using the cicsts_jdbc-1.0 feature

A CICS® Liberty JVM server can be configured to use JDBC type 2 connectivity with a DataSource or the java.sql.DriverManager interface to access DB2® databases from Java™ applications.

Before you begin

Although you can configure CICS Liberty to access DB2 with type 2 connectivity using the cicsts_jdbc-1.0 feature, the preferred method is to use the Liberty jdbc-4.x features. For more information, see Manually configuring a CICS DB2 JDBC type 2 driver data source for Liberty. However, if you want to use the DriverManager interface then you must use the cicsts_jdbc-1.0 feature as described in the following procedure.

Configure your CICS region to connect to DB2. For more information, see Defining the CICS DB2 connection.

Procedure

  1. Add the cicsts:jdbc-1.0 feature to the featureManager element. This enables use of the cicsts_jdbcDriver and cicsts_dataSource elements, used later in the server.xml file.
    <featureManager>
        <feature>cicsts:jdbc-1.0</feature>
    </featureManager>
  2. Add a cicsts_jdbcDriver element. This enables JDBC type 2 connectivity with the java.sql.DriverManager or javax.sql.DataSource interfaces. The cicsts_jdbcDriver element must refer to a library definition that specifies the library from which the JDBC driver components (the DB2 JDBC jar and native dll files) are to be loaded. Typical definitions might look like this:
    <cicsts_jdbcDriver libraryRef="defaultCICSDb2Library"/>
    <library id="defaultCICSDb2Library">
        <fileset dir="/usr/lpp/db2v11/jdbc/classes" includes="db2jcc4.jar db2jcc_license_cisuz.jar"/>
        <fileset dir="/usr/lpp/db2v11/jdbc/lib" includes="libdb2jcct2zos4_64.so"/>
    </library>
    Note: Only one cicsts_jdbcDriver element is required. If more than one is specified, only the last cicsts_jdbcDriver element in the server.xml file is used and the others are ignored.
  3. If you require only java.sql.DriverManager support, then the preceding steps are sufficient. To access DB2 through a DataSource definition then a cicsts_dataSource element is required, but the preferred method for DataSource access is Manually configuring a CICS DB2 JDBC type 2 driver data source for Liberty. A cicsts_dataSource requires a jndiName attribute to define the JNDI name that is referenced by your application. A definition might look like this:
    <cicsts_dataSource id="defaultCICSDataSource" jndiName="jdbc/defaultCICSDataSource"/>
    Tip: The DataSource class that is used is com.ibm.db2.jcc.DB2SimpleDataSource, which implements javax.sql.DataSource.
  4. Optional: You can set attributes for the cicsts_dataSource by using a properties.db2.jcc element. The following example shows how to do this:
    <cicsts_dataSource id="defaultCICSDataSource" jndiName="jdbc/defaultCICSDataSource">
        <properties.db2.jcc currentSchema="DB2USER" fullyMaterializeLobData="true" />
    </cicsts_dataSource>
    Some of the attributes, which can be specified on the properties.db2.jcc element are not valid for DataSources with type 2 connectivity. If these invalid attributes are specified, they are ignored and a warning message is issued. The following attributes are not valid:
    • driverType
    • serverName
    • portNumber
    • user
    • password
    • databaseName

Results

Liberty can connect to DB2 databases with JDBC type 2 connectivity.
Note: Dynamic updates of the cicsts_dataSource and its components are not supported. Updating the configuration while the Liberty server is running can result in DB2 application failures. You should recycle the server to activate any changes.


config_db2ds_cicsts_jdbc.html | Timestamp icon Last updated: Sunday, 4 June 2017