To use Java™ programs in the CICS® DB2® environment, you need to apply the following
system and setup requirements:
Requirements for Java programs and enterprise
beans, which run in a JVM
For Java programs and enterprise beans, which run in the IBM® Java
Virtual Machine (JVM), the following APARs are required on DB2:
- PQ84783 on DB2 6.1
- PQ84783 (JDBC 1.2 and 2.0 drivers) and PQ86525 (DB2 Universal JDBC Driver)
on DB2 7.1
- PQ84783 (JDBC 2.0 driver) and PQ86525 (DB2 Universal JDBC Driver) on DB2
8.1

To use the DB2-supplied JDBC drivers with
Java programs and enterprise beans, you need to amend the JVM profiles that
are used by the Java programs or enterprise beans. You need to add a DB2-supplied
zip file (or for the DB2 Universal JDBC Driver, three DB2-supplied jar files)
to the trusted middleware class path, and a DB2-supplied directory containing
dynamic load libraries to the library path for the JVM. (Note that if the
JVM is a worker JVM that uses the shared class cache, its trusted middleware
class path and library path are taken from the JVM profile for the master
JVM that initializes the shared class cache, not from the JVM profile for
the worker JVM itself.)
Java Applications in CICS tells you how to locate and customize
JVM profiles. If you have any applications that use the JDBC 2.0 API, you
must use either the JDBC 2.0 driver (which supports a subset of the JDBC 2.0
application programming interface), or the DB2 Universal JDBC driver. The
JDBC 2.0 driver and the DB2 Universal JDBC Driver also support applications
written using the JDBC 1.2 API.
- For the JDBC 1.2 driver, the JDBC 2.0 driver, and the
DB2 Universal JDBC Driver, you also need to add the DB2 directory containing
the serialized profile DSNJDBC_JDBCProfile.ser either to the JVM's
standard class path (the CLASSPATH option in the JVM profile), or to its shareable
application class path (the ibm.jvm.shareable.application.class.path option in the JVM properties file). If the JVM is a worker JVM that
uses the shared class cache, its shareable application class path is taken
from the JVM profile for the master JVM that initializes the shared class
cache, but its standard class path is taken from the JVM profile for the worker
JVM itself. The serialized profile is initially created in the DB2 directory
where the command db2genjdbc was issued, but it might have been
subsequently moved to another location. The directory that needs to be added
to the JVM's class path is the directory that currently contains the serialized
profile. When you have added the directory to the JVM's class path, you also
need to ensure that the DB2 system property db2sqljjdbcprogram=dsnjdbc is set in the JVM properties file for the JVM. This system property
is the default, so it does not need to be added to the JVM properties file
if it is not present. For full details, see the DB2 Universal Database™ for OS/390® and z/OS® Application Programming Guide and Reference for Java which is appropriate
to your version of DB2.
Requirements for the DB2-supplied JDBC drivers
- To use the JDBC 1.2 driver or the JDBC 2.0 driver shipped with DB2 Version
7 or later, or the DB2 Universal JDBC Driver, you need
to add the SDSNLOD2 library to the CICS STEPLIB concatenation. The JDBC 1.2
driver shipped with DB2 Version 6 does not require this library.
- To enable your applications to use the DB2-supplied JDBC drivers, you
need to name the drivers by using the jdbc.drivers system property
in the JVM properties files that are referenced by the JVM profiles used by
your applications. The CICS-supplied sample JVM properties files contain commented-out
examples of how to do this. Java Applications in CICS tells you
how to locate and customize JVM properties files. Naming the JDBC drivers
removes the need for applications to load the drivers themselves using the Class.forName() method. Instead, the DriverManager class loads the required
class for the application. The name of the driver is the same for the JDBC
1.2 driver, the JDBC 2.0 driver, and the DB2 Universal
JDBC Driver, so if you follow this method, you do not need to change your
existing applications or your JVM properties files when you migrate from one
driver to another.
- When running the JDBC driver in a CICS environment, you might want to
alter the system properties in your JVM properties files to tailor your environment.
With CICS, the DB2 environment variable DB2SQLJPROPERTIES, which names a system
properties file to be used by the JDBC driver, is not used. Instead, you can
set system properties related to the JDBC driver in the JVM properties files.
These are the files named by the JVMPROPS parameter in your JVM profiles.
If you want to alter the system properties, note that most DB2 JDBC driver
system properties are not used in a CICS environment.The
appendixes of the DB2 Universal Database for OS/390 and z/OS Application Programming Guide and Reference for Java have a list of the properties that are not used
or have a different meaning in a CICS environment, and the document also contains
the full list of DB2 JDBC driver properties. For DB2 Version 6, the document
number is SC26-9018, the full list of driver properties is in Chapter 7, and
the changes to properties in a CICS environment are in Appendix B. For DB2
Version 7, the document number is SC26-9932, the full list of driver properties
is in Chapter 6, and the changes to properties in a CICS environment are in
Appendix B. For DB2 Version 8, the document number is SC18-7414, the full
list of driver properties is in Chapter 7, and the changes to properties in
a CICS environment are in Appendix A.
- If you want to use the DataSource interface, which is supported by the
JDBC 2.0 driver provided by DB2 Version 7 or later or the
DB2 Universal JDBC Driver, to connect to a database, you need a suitably configured
naming server. If you need to configure a naming server, see Java Applications in CICS,
in particular the topics Defining name servers, Enabling JNDI references, Setting
up an LDAP server, and Setting up a COS Naming Directory
Server.
Requirements for using Java 2 security with
JDBC or SQLJ
- To use JDBC or SQLJ from a Java program or enterprise bean with a Java
2 security policy mechanism active, you must use the JDBC 2.0 driver or
the DB2 Universal JDBC Driver. The JDBC 1.2 driver does not support Java 2
security, and will fail with a security exception.
- To activate a Java 2 security policy mechanism, you need to amend your
JVM properties files. These are the files named by the JVMPROPS parameter
in your JVM profiles. Java Applications in CICS has more information
about setting up a Java 2 security policy mechanism. In summary, to use the
default Java 2 security manager for a JVM with a particular JVM profile, include
the following statement in the JVM properties file that is referenced by that
JVM profile:
java.security.manager=default
You also need to name
your Java 2 security policy file in the JVM properties file, using the following
statement:
java.security.policy= /directory/tree/file.name
CICS supplies
an example Java 2 security policy for use with Java programs or enterprise
beans in the CICS environment, and you can find the example file at /usr/lpp/cicsts/cicsts31/lib/security/dfjejbpl.policy, where cicsts31 is
your chosen value for the USSDIR installation parameter that you defined when
you installed CICS TS.
- To use JDBC and SQLJ, you need to amend your Java 2 security policy to
grant permissions to the JDBC driver, by adding the following lines:
grant codeBase "file:/usr/lpp/db2710/-" {
permission java.security.AllPermission;
};
In place of db2710, specify a directory below which
all your DB2 Version 7 libraries are located. The permissions are applied
to all the directories and files below this level. The example Java 2 security
policy dfjejbpl.policy does not contain this statement, so you
need to add it.
- In your Java 2 security policy, you also need to grant read permissions,
by adding the following lines:
grant {
// allows anyone to read properties
permission java.util.PropertyPermission "*", "read";
};
If you do not do this, running a Java program produces AccessControlExceptions
and unpredictable results. The example Java 2 security policy dfjejbpl.policy already contains this statement.