A CICS® Liberty JVM server can be configured to use
a JDBC DataSource with type 4 connectivity to access DB2®
databases from Java™ applications.
Before you begin
The Liberty DB2 DataSource with type 4 connectivity does not use the CICS
DB2 connection resource. However,
if you do not
have APARs PI18798 and PI18799 applied, you need to add the DB2 SDSNLOAD and SDSNLOD2 libraries
to the CICS STEPLIB concatenation.
About this task
This task explains how to manually define the elements that are required in the
server.xml configuration file to enable JDBC type 4 driver connectivity to a
local or remote DB2 database. Updates that are made to a DB2 database that uses type 4 connectivity do not use the CICS
DB2 connection resource. They are not part of the CICS unit of work unless the DataSource connection is of type
javax.sql.XADataSource, and they are made within a JTA user transaction, see Java Transaction API (JTA).
Procedure
- Add the jdbc-4.0 feature to the featureManager element. This enables use of
the dataSource and jdbcDriver elements that are used later in
the server.xmlfile.
<featureManager>
<feature>jdbc-4.0</feature>
</featureManager>
- Add dataSource and jdbcDriver elements.
The dataSource 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:
<dataSource jndiName="jdbc/defaultCICSDataSource">
<jdbcDriver libraryRef="db2Lib"/>
<properties.db2.jcc driverType="4"
serverName="winmvs2c.hursley.ibm.com"
portNumber="41100"
databaseName="DSNV11P2"
user="DBUSER"
password="{xor}Lz4sLCgwLTs="/>
</dataSource>
<library id="db2Lib">
<fileset dir="/usr/lpp/db2v11/jdbc/classes" includes="db2jcc4.jar
db2jcc_license_cisuz.jar" />
</library>
If you do not have APARs PI18798 and PI18799 applied you need to add a fileset entry for
the DB2 native library to the library configuration, for example:
<fileset dir="/usr/lpp/db2v11/jdbc/lib" />
The
dataSource specifies the jndiName attribute that is referenced
by your application program when you are establishing a connection to that DataSource. The required
properties are set in the properties.db2.jcc element as follows:- driverType
- Description: Database driver type, must be set to 4 to use the pure Java driver.
- Default value: 4
- Required: false
- Data type: int
- serverName
- Description: The host name of server where the database is running. This is the SQL DOMAIN value
of the DB2 DISPLAY DDF command.
- Default value: localhost
- Required: false
- Data type: string
- portNumber
- Description: Port on which to obtain database connections. This is the TCPPORT value of the DB2 DISPLAY DDF command.
- Default value: 50000
- Required: false
- Data type: int
- databaseName
- Description: specifies the name for the data source. This is the LOCATION value of the DB2 DISPLAY DDF command.
- Required: true
- Data type: string
- user
- Description: The user ID used to connect to the database.
- Required: true
- Data type: string
- password
- Description: The password of the user ID used to connect to the database. The value can be
stored in clear text or encoded form. It is recommended that you encode the password. To do so, use
the securityUtility tool with the encode option, see Liberty: securityUtility command.
- Required: true
- Data type: string
Results
The Liberty server, when started, is configured to allow access to DB2 databases through a JDBC type 4 connectivity. For more information, see
Java Database Connectivity 4.1.