80 DB2 UDB for Linux on iSeries: Implementation Guide
Figure 3-36 Type4 JDBC driver provided by DB2 UDB for Linux
The universal JDBC driver is the new JDBC driver which is provided with DB2
Version 8. This JDBC driver implements DRDA in it and can access all DB2 UDB
for LUW directly.
Since type 3 is the applet driver, a typical Java application is supposed to use
type 2 or type 4 driver. In this book, only type 2 and type 4 are discussed.
3.8.3 JDBC type 2 driver scenario
The JDBC type 2 driver relies on an OS-specific library (shared library) in the
database client-end to communicate with an RDBMS. In the case of Linux
application accessing DB2 UDB for iSeries, this library is packaged in the DB2
Client. In other words, you need a DB2 Client installed on the machine where the
JDBC type 2 application runs. This scenario is described in Figure 3-37.
DB2 Engine
DB2 UDB
for iSeries
OS/400
DRDA AS
DB2 Engine
DB2 UDB
for Linux
Linux
Java program
DB2 Type
4
JDBC driver
Client
Chapter 3. Connectivity with DB2 UDB for iSeries 81
Figure 3-37 DB2 type2 JDBC driver Scenario
How the JDBC type 2 driver works
The application will load the JDBC driver and the driver will use the shared library
to communicate with the DB2 server. Actually, DB2 UDB for Linux on iSeries
provides two different type 2 drivers:
򐂰 The CLI JDBC driver is provided in the file db2java.zip. The implementation
package name is COM.ibm.db2.jdbc.app.DB2Driver. This driver has been
used for the current J2EE certifications.
򐂰 The Universal JDBC driver, which is introduced as type 4 before, can also be
used as the type 2 driver. This driver is provided in the file db2jcc.jar. The
implementation package name is com.ibm.db2.jcc.DB2Driver. This driver is
new to DB2 UDB V8.1. In the initial implementation (V8.1), this driver was for
direct Java connectivity to DB2 servers using a type 4 driver architecture. In
Note: On the Linux side, you don’t need the DB2 Client, because it is
integrated in every edition of DB2 UDB for LUW available for iSeries, including
DB2 ESE.
DB2
Engine
AS05
Database
OS/400
Hostname: as05
DRDA AS
Schema : SAMPLEDB01
Alias : OS400
DB2 Engine
SAMPLE
Database
Linux on iSeries
Hostname: linux02
DB2 Connect
(DRDA AR)
Schema : DB2INST1
Alias : SAMPLE
JDBC type 2
driver
DB2 ESE
TestJDBC.java
82 DB2 UDB for Linux on iSeries: Implementation Guide
DB2 V8.1.2, you can use this driver in a type 2 architecture with the local DB2
Client. One of the key reasons for using the driver in a type 2 architecture is
for local application performance and for distributed transaction support. The
Universal JDBC type 2 driver supports distributed transactions using
com.ibm.db2.jcc.DB2XADataSource and connection pooling using
com.ibm.db2.jcc.DB2ConnectionPoolDataSource.
Both of these JDBC type 2 drivers are supported with WebSphere Application
Server. You can also use JDBC type 2 drivers to support Java-based client
applications.
Configuration
This section provides a step-by-step process of JDBC type 2 driver configuration.
1. Locate the JDBC drivers path. Usually, all JDBC drivers are in:
HOME_DIR/sqllib/java,
Here HOME_DIR is the instance owner’s home directory. In this scenario, the
instance name is db2inst1, thus the full path is:
/home/db2inst1/sqllib/java
2. Table 3-1 determines the appropriate JDBC driver you can use:
Table 3-1 Implementation Package JDBC drivers on DB2 UDB for Linux on iSeries
The CLI JDBC driver supports most existing applications, therefore it is
recommended to customers considering compatibilities important. The DB2
Universal JDBC driver is recommended for new users.
Note: Here are two other directories that may contain the JDBC drivers file:
򐂰 /opt/IBM/db2/V8.1/java
򐂰 /opt/IBM/db2/V8.1/java12
We recommend that you do
not to use them. They are the original
copies for the creation of DB2 instances.
򐂰 HOME_DIR/sqllib/java12
We recommend that you do
not to use it, because it is a back-level auxiliary
directory for JDBC 1.2 compatibility.
Driver Name Type Implementation Package
CLI JDBC driver 2 COM.ibm.db2.jdbc.app.DB2Driver
Universal JDBC driver 2 and 4 com.ibm.db2.jcc.DB2Driver

Get DB2 for Linux on iSeries: Implementation Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.