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.
Procedure
-
Add the
jdbc-4.1
or jdbc-4.0
feature to the
server.xml file.
Use the jdbc-4.0 feature if you use Java EE 6, or
jdbc-4.1 if you use Java EE 7.
<featureManager>
<feature>jdbc-4.1</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.
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 JVM server is configured to allow access to Db2 databases by using JDBC type 2
connectivity through a CICS DB2CONN resource.