After you install the IBM Data Server Driver for JDBC and
SQLJ, you can prepare and run JDBC or SQLJ applications.
Before you begin
Before you install the
IBM Data Server Driver for JDBC and
SQLJ, you need the following software.
- An
SDK for Java, 9 or later.
- A minimum Java Runtime Engine (JRE) version 1.8. The JDBC/SQLJ driver supports the 4.3 spec
APIs, provided that the JRE used is JRE9 and higher.
- JVM native threads support
Any JVMs that run Java™
applications that access Db2® databases must
include native threads support. You can specify native threads as the default thread support for
some JVMs by setting the THREADS_FLAG environment variable to
"native". Refer to the documentation for your Java environment for instructions on making native threads the default on your
system.
- Unicode support for System i servers
If any SQLJ
or JDBC programs will use
IBM Data Server Driver for JDBC and
SQLJ type 4 connectivity to connect to a
Db2 for IBM i
server, the System i operating system must support the
Unicode UTF-8 encoding scheme. The following table lists the System i PTFs that you need for Unicode UTF-8 support:
Table 1. System i PTFs for Unicode UTF-8 support
System i
version |
PTF numbers |
V5R3 or later |
None (support is included) |
- A JDBC driver license JAR file, if you plan to use the IBM Data Server Driver for JDBC and
SQLJ to connect to a Db2 for z/OS® or Db2 for IBM i data server.
The following table lists the license file names and
Db2 Connect editions.
Table 2. License JAR file names and Db2 Connect editions
License JAR file name |
Db2 Connect edition |
db2jcc_license_consvZS.jar |
Db2 Connect Unlimited Edition for System z |
db2jcc_license_consvIS.jar |
Db2 Connect Unlimited Edition for System i |
db2jcc_license_consvAS.jar |
Db2 Connect Application Server Edition |
db2jcc_license_consvEE.jar |
Db2 Connect Enterprise Edition |
db2jcc_license_consvAAS.jar |
Db2 Connect Application Server Advanced Edition |
db2jcc_license_consvAZS.jar |
Db2 Connect Unlimited Advanced Edition for System z |
The JDBC driver license file is included only with all Db2 Connect
Server editions. After you obtain Db2 Connect, you need to go to Passport Advantage to download the activation key for the Db2 Connect
Server edition that you own.
Restrictions
If you install the IBM Data Server Driver for JDBC and
SQLJ on a Windows 64-bit
operating system, you cannot use IBM Data Server Driver for JDBC and
SQLJ type 2 connectivity to connect to a Db2 instance from a 32-bit Java application.
Procedure
To install the IBM Data Server Driver for JDBC and
SQLJ:
- During the Db2 installation process, select
Java support
on UNIX or Linux®, or JDBC support
on Windows. These selections
are defaults. If you have already installed
Db2 without JDBC support, you can run the installation process
in
Custom
mode to add JDBC support.
Selection
of Java support
or JDBC support
causes
the installation process to perform the following actions:
- Installs the IBM Data Server Driver for JDBC and
SQLJ class
files.
The files are placed in the
sqllib\java directory for Windows systems, or the
sqllib/java directory for UNIX or Linux systems.
Important: Modify the
CLASSPATH environment variable to include
db2jcc4.jar and
sqlj4.zip.
You must also make this
change in every Db2 command line window
that you open.
- If the IBM Data Server Driver for JDBC and
SQLJ client license file exists, the installation process installs the license file and modifies the CLASSPATH value to include it.
After you download the license JAR file to your client machine, you need to add the file path and file name of the license file to the CLASSPATH value of your
Db2 client application. For example, if the license file is in the path
sqllib\java (on Windows systems) or
sqllib/java (on UNIX or Linux systems), update the CLASSPATH value using the following syntax:
Replace
license-jar-file-name with the license JAR file name in
License JAR files and Db2 Connect editions that corresponds to the
Db2 Connect edition that you use to connect to the data server.
The file is placed in the sqllib\java directory for Windows systems, or the sqllib/java directory for UNIX or Linux systems.
Client license files are not required for connections to Db2, Cloudscape, or IBM
Informix® databases from the IBM Data Server Driver for JDBC and
SQLJ version 3.50 or later. Client license files are not required for direct connections to Db2 for z/OS if Db2 Connect Unlimited Edition
for System z® server license activation is performed.
Recommendation: If you connect to Db2 for z/OS data servers directly, rather than through a Db2 Connect gateway, and you use Db2 Connect Unlimited Edition
for System z 9.7 Fix Pack 3 or later, you must activate the server license key for Db2 Connect Unlimited Edition
for System z. You must activate the license key on each z/OS subsystem or data sharing group to which you will connect. See the z/OS information for details on server license activation.
- Installs IBM Data Server Driver for JDBC and
SQLJ native libraries for support of IBM Data Server Driver for JDBC and
SQLJ type 2 connectivity.
The files are placed in the sqllib\bin directory for Windows systems,
or the sqllib/lib directory for UNIX or Linux systems.
The file names are:
- libdb2jcct2.so
- For AIX®
and Linux
- db2jcct2.dll
- For Windows
- Customize the driver-wide configuration properties, if
any of the defaults are inappropriate.
- Configure TCP/IP.
Servers must be configured
for TCP/IP communication in the following cases:
- JDBC or SQLJ applications that use IBM Data Server Driver for JDBC and
SQLJ type 4 connectivity.
- JDBC or SQLJ applications that use IBM Data Server Driver for JDBC and
SQLJ type 2 connectivity, and specify the server and port number in the connection URL.
Ensure that the TCP/IP listener is running. To activate
the TCP/IP listener:
- Set the environment variable DB2COMM to TCPIP:
- Update the database manager configuration file with
the TCP/IP service name as specified in the services file:
db2 update dbm cfg using svcename TCP/IP-service-name
The port
number used for applets and SQLJ programs must be the same as the
TCP/IP svcename number used in the database manager
configuration file.
- Execute the db2stop and db2start commands for the service name setting to take
effect.
- On Db2 servers on which you plan to run Java stored procedures or user-defined functions,
update the database manager configuration to include the path where
the SDK for Java is located.
You can do this by entering commands similar to these on
the server command line:
To verify the correct value for the
jdk_path field in the
Db2 database manager
configuration, enter the following command on the database
server:
db2 get dbm cfg
You might want to redirect the output to a file for
easier viewing. The
jdk_path field appears near the beginning of the
output.
- If you plan to call SQL procedures that are on Db2 servers from Java programs, and the date and time format that is associated with the
territory code of the database servers is not the USA format,
take the following actions:
- Set the DB2_SQLROUTINE_PREPOPTS registry variable on the database servers to indicate that the default
datetime format is ISO:
db2set DB2_SQLROUTINE_PREPOPTS="DATETIME ISO"
- Redefine any existing SQL procedures that you plan to
call from Java programs.
These steps are necessary to ensure that the calling application
receives date and time values correctly.
-
If you plan to access Db2 for z/OS database servers
with your Java applications, follow the instructions in
"Special setup for accessing Db2 for z/OS servers from Java programs."