Connecting to DB2

You can use the information and links provided here to learn to connect the JDBC connector to DB2.

The IBM® driver for JDBC and SQLJ bundled with IBM Security Directory Integrator was obtained from http://www-306.ibm.com/software/data/db2/java. It is JDBC 1.2, JDBC 2.0, JDBC 2.1 and JDBC 3.0 compliant.

Information about the JDBC driver for IBM DB2® is available online; a starting point and example for configuration purposes is the section on "How JDBC applications connect to a data source" in the DB2 Developer documentation. This driver may or may not suit your purpose.

Driver Licensing

This driver does not need further licensing for DB2 database systems (that is, the appropriate license file, db2jcc_license_cu.jar is already included), except DB2 for z/Series and iSeries. In order for the driver to be able to communicate with the latter two systems you would need to obtain the DB2 Connect™ product, and copy its license file, db2jcc_license_cisuz.jar, to the jars/3rdparty/IBM directory. In addition, since this driver is a FAT client with natively compiled code (.dll/.so), the DB2 Connect installation path needs to be added to the PATH variable for these libraries to be used.

Based on the JDBC driver architecture DB2 JDBC drivers are divided into four types.
  1. DB2 JDBC Type 1

    This is an DB2 ODBC (not JDBC) driver, which you connect to using a JDBC-ODBC bridge driver. This driver is essentially not used anymore.

    A JDBC Type 1 driver can be used by JDBC 1.2 JDBC 2.0, and JDBC 2.1.

    To configure ODBC, see Specifying ODBC database paths.

  2. DB2 JDBC Type 2

    The DB2JDBC Type 2 driver is quite popular and is often referred to as the app driver. The app driver name comes from the notion that this driver will perform a native connect through a local DB2 client to a remote database, and from its package name (COM.ibm.db2.jdbc.app.*).

    In other words, you have to have a DB2 client installed on the machine where the application that is making the JDBC calls runs. The JDBC Type 2 driver is a combination of Java™ and native code, and will therefore usually yield better performance than a Java-only Type 3 or Type 4 implementation.

    This driver's implementation uses a Java layer that is bound to the native platform C libraries. Programmers using the J2EE programming model will gravitate to the Type 2 driver as it provides top performance and complete function. It is also certified for use on J2EE servers.

    The implementation class name for this type of driver is com.ibm.db2.jdbc.app.DB2Driver.

    The JDBC Type 2 drivers can be used to support JDBC 1.2, JDBC 2.0, and JDBC 2.1.

  3. DB2 JDBC Type 3

    The JDBC Type 3 driver is a pure Java implementation that must talk to middleware that provides a DB2 JDBC Applet Server. This driver was designed to enable Java applets to access DB2 data sources. An application using this driver can talk to another machine where a DB2 client has been installed.

    The JDBC Type 3 driver is often referred to as the net driver, appropriately named after its package name (COM.ibm.db2.jdbc.net.*).

    The implementation class name for this type of driver is com.ibm.db2.jdbc.net.DB2Driver.

    The JDBC Type 3 driver can be used with JDBC 1.2, JDBC 2.0, and JDBC 2.1.

  4. DB2 JDBC Type 4

    The JDBC Type 4 driver is also a pure Java implementation. An application using a JDBC Type 4 driver does not need to interface with a DB2 client for connectivity because this driver comes with Distributed Relational Database Architecture™ Application Requester (DRDA® AR) functionality built into the driver.

    The implementation class name for this type of driver is com.ibm.db2.jcc.DB2Driver.

    The latest version of this driver (9.1) supports SSL connections; this requires setting a property in the Extra Provider Parameters field. For more information see http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.apdv.java.doc/doc/rjvdsprp.htm. Note that the target database must be set up such that it accepts incoming SSL connections.

If the JDBC Connector's query schema throws an exception, or the Add/Update action on JDBC tables fails for BLOB data types, contact your database administrator and request that the required stored procedure for retrieving the schema be installed. For more information about accessing DB2 from Java, see also Overview of Java Development in DB2 UDB for Linux, UNIX, and Windows.