A CICS® Liberty JVM server can be configured to use a JDBC DataSource with type 2 connectivity through CICS to access Db2® databases from Java™ applications.
About this task
This task explains how to define the elements that are required in
server.xml to enable JDBC type 2 driver connectivity to a local Db2 database.
Java 17 To enable Db2 type 2 connectivity when you
are running Java 17, add
LIBPATH_SUFFIX=/usr/lpp/db2v12/jdbc/lib
to the JVM profile.
Procedure
-
Add the
jdbc-4.0
, jdbc-4.1
, jdbc-4.2
, or
jdbc-4.3
feature to the server.xml file.
<featureManager>
<feature>jdbc-4.2</feature>
</featureManager>
-
Add a library element to the server.xml file to specify the location on
zFS of the JDBC driver.
<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>
-
To access Db2 through a
DataSource definition, a dataSource element is required. The
jndiName attribute is required to define the JNDI name that is referenced by your
application.
Note: As of JDBC 4.3, the default dataSource
type is javax.sql.XADataSource
, which is not supported by the Db2 type 2 JDBC driver. The type must be set to
javax.sql.ConnectionPooledDataSource
or javax.sql.DataSource
for Db2 type 2 data sources.
You can set attributes for the
dataSource by using
a
properties.db2.jcc element. The following example shows how to do
this:
<dataSource id="defaultCICSDataSource" jndiName="jdbc/defaultCICSDataSource" transactional="false">
<jdbcDriver libraryRef="defaultCICSDb2Library"/>
<properties.db2.jcc driverType="2"/>
<connectionManager agedTimeout="0"/>
</dataSource>
transactional="false"
is required to allow CICS to manage the
transactions.
driverType="2"
is required to use the type 2 connectivity to
Db2.
agedTimeout="0"
is required to disable Liberty connection pooling.
Liberty connection pooling is not required as the DB2CONN resource provides Db2 connection pooling.
Results
The Liberty server is configured to allow access to Db2 databases by using JDBC type 2 connectivity through a CICS DB2CONN resource.