DB2 JDBC Driver Four introduction--------finally solved the problem of WebSphere project to Tomcat (this article is wonderful, so reprint reservation)

Source: Internet
Author: User
Tags connection pooling db2 db2 client db2 connect odbc websphere application server
JDBC Driver Uncover

A common source of confusion for Java is that JDBC has different versions, and JDBC drivers have different types that can be used by different versions of Java. Also, the new Java specification is always under development because the related functionality is continually being extended through the Java Community process (Java Community process,http://www.jcp.org). JDBC version

The DB2 Universal database V8.1 supports the JDBC V2.1 specification and the partial JDBC 3.0 specification. A plan to fully support JDBC 3.0 requirements with the Universal JDBC driver is underway.

The JDBC driver is certified as a component of the Java solution. The results of the driver certification are always posted on the Sun Compatibility Web site. JDBC Driver Architecture

The JDBC driver architecture is divided into four different types. Type 1 type 2 Type 3 Type 4 JDBC type 1 driver

The JDBC Type 1 driver is based on the Jdbc-odbc Bridge. Therefore, ODBC drivers can be used in conjunction with this type of JDBC driver (provided by Sun). IBM does not support Type 1 drivers, so it is not a recommended environment. Figure 1 shows an example of a JDBC Type 1 driver:

Figure 1. JDBC Type 1 driver JDBC Type 2 driver

The JDBC Type 2 driver relies on an operating system-specific library (shared library) to communicate with an RDBMS. The application will load this JDBC driver, and the driver will use the shared library to communicate with the DB2 server. DB2 UDB for Linux, UNIX® and windows®v8.1 provide two different type 2 drivers: The old/CLI JDBC driver is available in file Db2java.zip. The implementation package name is COM.ibm.db2.jdbc.app.DB2Driver. This driver has been used for Java EE authentication. The alias "app driver" originates from an idea and its package name: This driver will perform a local connection through the local DB2 UDB client of the remote database. The Universal JDBC driver is provided in file Db2jcc.jar. The implementation package name is Com.ibm.db2.jcc.DB2Driver. This driver is a new feature in DB2 UDB for Linux, UNIX, and Windows V8.1. In the initial implementation (V8.1), this driver is used to make a direct Java connection to the DB2 server using the Type 4 driver architecture. In DB2 V8.1.2, you can use this driver in the Type 2 architecture. One of the main reasons for using this driver in the Type 2 architecture is for local application performance and distributed transaction support. The Universal JDBC Type 2 driver uses Com.ibm.db2.jcc.DB2XADataSource and Com.ibm.db2.jcc.DB2ConnectionPoolDataSource to support distributed transaction and connection pooling, respectively.

You can use the JDBC Type 2 driver to support JDBC applications. WebSphere application Server supports both type 2 drivers at the same time. Note: The old/CLI Type 2 driver will not be enhanced in future releases.

Figure 2 shows the typical topology of an application that uses the JDBC Type 2 driver:

Figure 2. Application JDBC Type 3 driver with JDBC Type 2 driver

The JDBC Type 3 driver is a pure Java implementation that must communicate with the DB2 JDBC Applet server (DB2 JDBC applet servers) to access DB2 data. This class of drivers is designed to enable Java applets to access DB2 data sources. In the scenario shown in Figure 3, the application communicates with another machine that has the DB2 client installed.

Figure 3. Typical application scenarios that use the Type 3 JDBC driver

The JDBC Type 3 driver is often referred to as the "network (net) driver", which is named after its package name, COM.ibm.db2.jdbc.net. DB2 V8.1 supports network drivers that can be used with JDBC applications.

The Type 3 driver requires that the Db2java.zip driver always be at the same level of maintenance as the DB2 Applet server. This is not a problem if the driver is used within the applet, because the browser downloads the corresponding Db2java.zip file during the execution of the application. Many customers use the Type 3 driver instead of the type 2 driver to avoid the required DB2 client installation and the required DB2 CATALOG Database command, which is used to create the data that is necessary for Type 2 connections using the old/CLI driver. Currently, WebSphere application server and other Java EE servers do not support the IBM Type 3 driver because the driver does not support distributed transactions (JTA). Future versions do not enhance the Type 3 driver.

We encourage the use of the generic JDBC type 4 driver to override the Type 3 driver. JDBC Type 4 driver

The Type 4 driver is a Java-only JDBC driver that connects directly to the database server. DB2 UDB for Linux, UNIX, and Windows V8.1 introduced a Type 4 driver called the Universal JDBC Driver (Universal JDBC driver). The universal JDBC driver is provided in file Db2jcc.jar. Its implementation package name is Com.ibm.db2.jcc.DB2Driver.

Note that universal type 2 and generic type 4 drivers have the same implementation class name. There are two ways to distinguish which driver the DB2 will instantiate internally: Use the connection attribute to determine whether the connection uses a shared library (type 2), or whether the driver will initiate a direct connection from the Java application (Type 4). Use a different connection URL pattern to indicate which of the type 2 and type 4 behaviors you want.

Example of Type 4 URL pattern: The string "Jdbc:db2://server1:50000/sample" requires the JDBC driver to connect the Java application directly to the database named "Sample" on the DB2 server, which is located in the DB2 service (host name is Server1) on the DB2 instance, and the DB2 server listens on port 50000.

Example of Type 2 URL pattern: string "Jdbc:db2:sample". Information about the DB2 server ("Server1") and the port ("50000") can be found in the DB2 client catalog directory.

The universal JDBC Driver is an abstract JDBC processor that is independent of the driver type connectivity or the target platform. The universal JDBC Drive is an architecture-independent JDBC driver for distributed and local DB2 UDB access. Because the universal JDBC driver is independent of any particular JDBC driver type connectivity or target platform, it supports all Java connectivity (type 4 drivers) and JNI connectivity (type 2 drivers) in a DB2 UDB driver instance. This driver can be used for stand-alone Java applications or multi-tier applications.

Important: in the case of DB2 UDB V8.1.2, the generic JDBC driver requires a license JAR file and Db2jcc.jar file in CLASSPATH. The following are the required license JAR files: for the cloudscape™network server V5.1:db2jcc_license_c.jar for DB2 UDB V8 for Linux, UNIX and Windows servers: db2j Cc_license_su.jar for the DB2 UDB for Iseries®and z/OS server (available with DB2 Connect and DB2 Enterprise server Edition): Db2jcc_license_ Cisuz.jar

A generic driver can query the database metadata directory and retrieve server error message text by using the prerequisite stored procedures preinstalled on the target server: for UDB V8 on Linux, UNIX, and Windows, these stored procedures are pre-installed. PTF UQ72081 and UQ72082 must be installed for the DB2 UDB for OS/390®V6. PTF UQ72083 must be installed for the DB2 UDB for os/390 and z/Os V7. The DB2 UDB V8 on the upcoming z/OS will pre-installed the required stored procedures. The DB2 UDB for iSeries v5r1 requires PTF SI06308, SI06300, SI06301, SI06302, SI06305, SI06307, and SI05872. The DB2 UDB for iSeries V5R2 requires PTF SI06541, SI06796, SI07557, SI07564, SI07565, SI07566, and SI07567. DB2 UDB for iSeries V5R3 will install the required stored procedures in advance.

The Type 4 JDBC driver implementation is shown in Figure 4. Note: The generic JDBC/SQLJ drivers (type 4 and type 2) that are connected to the DB2 for z/Os and os/390 from Linux, UNIX, and Java applications or applets on Windows require an appropriate license file ( Db2jcc_license_cisuz.jar). The license file is provided with the DB2 Connect product.

Figure 4. Type 4 JDBC Driver implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.