The description of the DB2 database driver type is the main content of this article. At the same time, this article also describes the early CLI-based Drivers, recent pure Java drivers, and the combination of CLI and Java. for a specific DB2 version, the driver has a specific driver and a general driver, which is obvious.
General description
In the database product line of IBM, there are many data access APIs provided by different versions, including the early CLI-based Drivers and recent pure Java drivers, and a combination of CLI and Java. for a specific DB2 version, the driver has a specific driver and a general driver, which is obvious.
However, the relationship between the DB2 database systems of many versions and the access drivers of many versions is quite complicated. therefore, when using IBM database products, you must pay attention to the version correspondence and selection of appropriate generic drivers. fortunately, IBM has begun to unify and pay attention to ease of use. These efforts have started from DB2 UDB V7. since then, according to the JDBC driver type in the Java field, IBM has three types of drivers.
The jdbc type 2 driver of DB2 enables Java applications to call db2through JDBC. The call to DB2 JDBC type 2 driver is converted to a Java local method. java applications using this driver must run on a DB2 client, and JDBC requests are forwarded to the DB2 server through this client. before using the DB2 JDBC application driver to access the data source in the DB2 UDB for iSeries or DB2 for OS/390 or z/OS environment, you must install DB2 Connect Version 8. DB2 JDBC type 2 driver supports most of the JDBC and SQLJ functions described in the JDBC 1.2 specification, and supports some functions described in the JDBC 2.0 specification.
DB2 jdbc type 3 driver, also known as applet or net driver, consists of a JDBC client and a JDBC server (the process name is db2jd. it can be used in the Applet or in the application.
DB2's jdbc type 4 driver is called a universal driver and implemented in Java only. This driver also supports SQLJ.
Currently, no JDBC driver for TYPE 1 is provided by IBM.
The packages of these drivers are: db2jcc. jar and sqlj.zip files, sqllib \ bin \ db2jcct2. dll (this file is required by type2 ).
Use
When connecting DB2 UDB V7.2 and DB2 UDB V8.1 using JDBC, if you encounter some confusing problems, you can check the JDK used in the development environment, switching from a known JDK provided by IBM (with versions 1.3 and 1.4) often solves your problem.
In the DB2 UDB V8.2 Personal Edition, the following test code Tests Three connection methods and provides the results:
- import java.sql.*;
- public class Employee {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Employee ee = new Employee();
- try {
Ee. testJcc (); // succeeded
Ee. testNet (); // succeeded
Ee. testApp (); // the error message returned when the DB2 access client needs to be installed for Type 2. if you want to access the remote DB2 database through type 2, you can catalog the remote database locally.
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
The above content is an introduction to the DB2 database driver type, and I hope you will get something.