Manually configuring Db2 type 2 connectivity with the CICS JDBC feature
The cicsts:jdbc-1.0 feature is used to configure JDBC in CICS® Liberty JVM servers to access Db2® databases with type 2 connectivity from Java™ applications. Db2 can be accessed using DataSources or a DriverManager.
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.
About this task
This task explains how to define the elements in server.xml and properties in the JVM profile to connect a local Db2 database with type 2 connectivity using the cicsts:jdbc-1.0. Your application can connect to Db2 using either DataSources with the javax.sql.DataSource class, or using a DriverManager, with the java.sql.DriverManager class.
Java 17Java 21 To enable Db2 type 2 connectivity when you
are running Java 17 or Java 21, add LIBPATH_SUFFIX=/usr/lpp/db2v13/jdbc/lib to
the JVM profile.
You can use the cicsts:jdbc-1.0 feature if you want to use DriverManager to connect to Db2.
Procedure
If you only use DriverManager support, the preceding steps are sufficient.
Results
cicsts_dataSource element and its components are
not supported. Updating the configuration while the Liberty server is running can result in Db2 application failures. Stop the
Liberty JVM server before making any changes to the cicsts_dataSource element, then
restart the Liberty JVM server.You can create an instance of a DriverManager by calling the java.sql.DriverManager.getConnection method in your applications.
You can look up an instance of javax.sql.DataSource through JNDI in
applications. The JNDI name of this DataSource is defined by the
jndiName attribute in the cicsts_dataSource element.
Example server.xml configuration for a Db2 DataSource with type 2 connectivity that uses the CICS JDBC feature
<server>
<!-- Install the JDBC feature -->
<featureManager>
<feature>cicsts:jdbc-1.0</feature>
</featureManager>
<!-- Configure the IBM Data Server Driver for JDBC and SQLJ for Db2 driver library -->
<library id="db2Library">
<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>
<!-- Configure the JDBC driver -->
<cicsts_jdbcDriver id="defaultCICSJdbcDriver" libraryRef="db2Library"/>
<!-- Configure the DataSource -->
<cicsts_dataSource id="defaultCICSDataSource" jndiName="jdbc/cicsDb2DataSource"/>
</server>