A CICS® Liberty JVM server can be configured to use
a JDBC DataSource with type 2 connectivity to access DB2®
databases from Java™ applications.
Before you begin
You should configure your CICS region to connect to
DB2 so that DataSource configurations can be dynamically
updated. For more information, see
Defining the CICS DB2 connection.
About this task
This task explains how to define the elements that are required in the
server.xml configuration file to enable JDBC type 2 driver connectivity to a
local DB2 database.
Procedure
- Add the jdbc-4.1 feature to the featureManager element. This enables use of the DataSource element, used later in the server.xml
file.
<featureManager>
<feature>jdbc-4.1</feature>
</featureManager>
- Add a Library element. This enables JDBC type 2 connectivity with the
javax.sql.DataSource interface. The Library definition specifies from where the JDBC driver components
(the DB2 JDBC jar and native dll files) are to be loaded.
Typical definitions might look like
this:
<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 then a
dataSource element is required. A dataSource element requires
a jndiName attribute 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>
Results
The Liberty server, when started, is configured to allow access to DB2 databases by using a JDBC type 2 connectivity.