Qondio
Front
Intel
IntelMart
Shares
My Qondio
Account
Joe > Intel > Learn to the DB2 UDB JDBC Universal Driver

qondio.com/ynWH PRINT EMAIL

Learn to the DB2 UDB JDBC Universal Driver

By Joe Lee

Compare the legacy JDBC driver with the new universal JDBC driver
In order to understand how we came to the development of the DB2 Universal Driver, you need to understand how the JDBC specification defines the different types of drivers in the Java world.
1. Type 1 driver:
o This type of driver code maps directly to a high level native API. JDBC and ODBC are similar APIs, so this type of driver is usually associated with the JDBC-ODBC bridge.
o This driver does not have too much context with respect to the DB2 UDB product.
2. Type 2 driver:
o A T2 driver has a native component that is part of the driver, but separate from the data access API.
o The native component and the Java component make up this driver.
o For DB2 UDB, the DB2 CLI libraries comprise the native component.
3. Type 3 driver:
o This is a Java client that communicates using a database independent protocol.
o Since the protocol is database independent, the advantage of this protocol falls to middleware servers that act as gateways to heterogeneous backend servers.
4. Type 4 driver:
o This driver is pure Java and implements the network protocol for a specific data source.
o The client connects directly to the data source.
As far as DB2 UDB is concerned, you only need to worry about the Type 2, 3, and 4 drivers. Now with this knowledge, you can look at specific information with respect to the Type 2 and Type 4 drivers and examine the advantages of using the Type 4 driver in your application development. Let's look at some specific comparisons of the legacy-based CLI Type 2 driver and the Type 4 Universal JDBC Driver.
Installation
DB2 JDBC support is provided as part of the Java enablement option for DB2 UDB clients and servers. No special installation is required; you just need to make sure that you have the appropriate Java developer kit downloaded for your particular platform. The DB2 Information Center contains detailed information on how to set up your environment for Java on both UNIX and Windows.
Table 1. Installation comparison
CLI legacy driver Universal driver
The physical representation of the legacy-based CLI driver is the db2java.zip file. The physical representation of the universal JDBC driver is the db2jcc.jar file.
In the UNIX environment, you can use the Type 2 legacy-based driver by making sure that you have sqllib/java/db2java.zip in your CLASSPATH. The same applies to Windows. In the UNIX environment, you can use the Type 4 universal driver by making sure you have both sqllib/java/db2jcc.jar and db2jcc_license_cu.jar in the CLASSPATH. Windows instructions are the same.
The support that is enabled for this driver is JDBC 2.0 and some JDBC 3.0. Support includes most implementations of JDBC 3.0, as long as you have JDK1.4.x installed as part of your Java package.
Connection
The difference between the two JDBC drivers is shown in the way that they make their connections. The essential function of JDBC is to connect to the database and send SQL statements to the server. It has the capability of processing a result set and sending it to the requestor.
Table 2. Connection comparison
CLI legacy driver Universal driver
The connection to the database occurs through a native database interface; in this case, DB2 uses CLI. The JDBC layer sits on top of CLI, and CLI is the native component that communicates with the database server. Everything is pure Java, and the way it communicates with the database server is though network communication. DB2 UDB uses distributed relational database architecture (DRDA) to communicate to the server and flow requests to the database server.
Since the legacy-based CLI driver requires common client code, it also requires a DLL/shared object. The DB2 product must be installed in order to use this driver. This is a pure Java driver and so can run independently of what product is installed on the machine where it runs. That is, it can be considered as a separate entity on its own and independent of the DB2 product it is shipped with.
Driver initialization
The way you actually write the code to load the driver changes depends on which driver you want to use. There are two ways the connection can be established. As with all JDBC resources, invoke the connections close method when you are done with the connection.
Table 3. Driver initialization comparison
CLI legacy driver Universal driver
There are three essential steps needed to load and make this connection:
1. Import the JDBC core classes (for example, import java.sql*).
2. Load the JDBC driver Class.forName (COM.ibm.db2.jdbc.app.DB2Driver).
3. Specify the connection URL:DriverManager getConnection jdbc:db2:coffebk. The universal driver supports both Type 2 and Type 4 connectivity from a single driver.h network communication. DB2 UDB uses distributed relational database architecture (DRDA) to communicate to the server and flow requests to the database server.
The way you tell whether you are using the Type 2 or Type 4 driver is from the form of the connection. The following indicates that a Type 2 or Type 4 driver is being used:

jdbc:db2//server:port/database
jdbc:db2//server/database

The following means that a Type 2 driver is being used:
jdbc:db2:database
You have the ability to use the Type 3 driver if you want, in which case the syntax for the driver initialization will be:COM.ibm.db2.jdbc.net.DB2Driver. You can toggle between the two drivers' material layers with the connection level that you use.
Features
The introduction of DB2 UDB, Version 8 has enabled Java development to become more versatile and programming independent. Most development efforts are now focused on adding new features, improved memory management, and stability in the new JDBC Universal Driver.
Table 4. Features comparison
CLI legacy driver Universal driver
This driver needs to specifically have the DB2 UDB product installed, as it relies on the native code of the product. This driver can be considered an independent product. It does not require the product to be installed, and it can be shipped with the many DB2 platforms that the product ships with.
Legacy driver versions are in line with DB2 UDB fix packs and, as such, are only shipped when a fix pack is released. The shipping of the JCC driver is independent of the fix pack. JCC drivers have their own versions and are shipped as needed by the release for any DB2 product. For example, DB2 V8.20 fp9 may ship with JCC driver version 2.3.9, whereas DB2 V8.20 OS/390 PTF UQ72081 may ship with JCC driver version 2.3.11.
Error handling
The two types of JDBC drivers handle errors in very different ways. The development of the error messages are still ongoing and in developing phases for the new driver, but newer versions hold more improved error handling for the universal driver. When you look at a typical JDBC exception, it will consist of an SQLErrorCode, SQLState, and SQLMessage.
Table 5. Error handling comparison
CLI legacy driver Universal driver
The legacy driver gets its error messages from the DB2 product and essentially spits out the entire error message back to the application. The universal driver does not attempt to recreate pre-existing SQL error codes that were issued by the legacy CLI/JDBC products. The universal driver has its own defined error codes in the range +/-4200 and +/-4299.
Undefined error codes issued by the universal driver are given the error code of -99999.
If an error comes from a DB2 subsystem like DB2 server of underlying DB2 client library, then JCC will just echo that error message.
Transaction management
A transaction is a set of one or more statements that are executed together as a unit of work (UOW). Transactions are used to make sure that all transactions that are part of a UOW are executed or that none of them are executed at all. With respect to the drivers, J2EE specifies simple transaction management.
Table 6. Transaction management
CLI legacy driver Universal driver
XA support has been enabled for this driver for a very long time. As of V8.20, XA support was enabled for the Type 4 JDBC universal driver.

Contributed by Joe on July 8, 2010, at 5:01 PM UTC.

PLEASE VISIT THE CONTRIBUTOR'S WEBSITE
All Free Download Drivers | Win 7 XP Drivers - DriversCat.com
Free, Driver Downloads, BIOS, Firmware
www.driverscat.com

Reactions

Vegetable Oil liked this intel. Apr 10, 2012

Rate This Intel

Please login or sign up to rate this intel.

Comments

Please login or sign up to add a comment.

Share

Copyright Notice

The copyright for this content entitled "Learn to the DB2 UDB JDBC Universal Driver" has been specified by the contributor as:

Public Domain

The copyright for this content has been relinquished by the author. The content may be used freely by anyone.

Login Here with
Any Email Address
Any Password
No account? Sign up.

Intel Contributor
This intel was contributed by Joe


Joe

Qondio Archive
May, 2012
123456
78910111213
14151617181920
21222324252627
28293031


2008
January, February, March, April, May, June, July, August, September, October, November, December
2009
January, February, March, April, May, June, July, August, September, October, November, December
2010
January, February, March, April, May, June, July, August, September, October, November, December
2011
January, February, March, April, May, June, July, August, September, October, November, December
2012
January, February, March, April, May

Sign Up
Not a member yet? Qondio is a powerful network for making it online. If you have a website to promote, we can help. Sign up and get in on the action.

About Qondio
Welcome to Qondio! Discover the awesome power this network can deliver by going to our About page. Or you could skip straight to the Sign Up form.

ABOUT
SUCCESS GUIDE
FEATURES
FAQ
ADVERTISE
CONTACT
USAGE POLICY
PRIVACY POLICY


TWITTER
FACEBOOK