In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the JDBC driver". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what the JDBC driver is.
A common source of confusion about Java is that there are different versions of JDBC, different types of JDBC drivers, and they can be used by different versions of Java. Moreover, new Java specifications are always under development because related capabilities are constantly being extended through the Java Community process (Java Community Process).
JDBC version
DB2 generic database V8.1 supports the JDBC V2.1 specification and part of the JDBC 3.0 specification. Plans are under way to fully support JDBC 3.0 requirements using the generic JDBC driver.
The JDBC driver is certified as a component of the J2EE solution. The results of driver certification are always posted on the Sun compatibility website.
JDBC driver architecture
There are four types of JDBC driver architectures.
◆ 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, the ODBC driver can be used in conjunction with such JDBC drivers (provided by Sun). IBM does not support the Type 1 driver, so it is not the recommended environment. Figure 1 shows an example of the JDBC Type 1 driver:
Figure 1. JDBC Type 1 driver
JDBC Type 2 driver
JDBC Type 2 drivers rely on operating system-specific libraries (shared libraries) to communicate with RDBMS. The application will load the 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 provided in the file db2java.zip. Its implementation package name is COM.ibm.db2.jdbc.app.DB2Driver. The driver is currently used for J2EE authentication. The nickname "app driver" derives from the idea that the driver will perform a local connection through the local DB2 UDB client of the remote database and its package name.
The generic JDBC driver is provided in the file db2jcc.jar. Its implementation package name is com.ibm.db2.jcc.DB2Driver. This driver is new in DB2 UDB for Linux, UNIX, and Windows V8.1. In the initial implementation (V8.1), this driver was 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 generic JDBC Type 2 driver uses com.ibm.db2.jcc.DB2XADataSource and com.ibm.db2.jcc.DB2ConnectionPoolDataSource to support distributed transactions and connection pooling, respectively.
You can use the JDBC Type 2 driver to support JDBC applications. WebSphere Application Server supports both Type 2 drivers. Note: the old / CLI Type 2 driver will not be enhanced in future releases.
Figure 2 shows a typical topology of an application that uses the JDBC Type 2 driver:
Figure 2. Applications that use the JDBC Type 2 driver
JDBC Type 3 driver
The JDBC Type 3 driver is a pure Java implementation that must communicate with a DB2 JDBC Applet server (DB2 JDBC Applet Server) to access DB2 data. This type of driver is designed to enable Java applet to access DB2 data sources. In the scenario shown in figure 3, the application communicates with another machine with the DB2 client installed.
Figure 3. Typical application scenarios using the Type 3 JDBC driver
The JDBC Type 3 driver is often referred to as the "net driver" and is named after its package name COM.ibm.db2.jdbc.net. DB2 V8.1 supports network drivers, which can be used in JDBC applications.
The Type 3 driver requires that the db2java.zip driver is always at the same level of maintenance as the DB2 Applet server. If the driver is used within applet, this is not a problem 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 necessary DB2 client installation and the necessary DB2 CATALOG DATABASE commands, which are used to create the database directory information necessary for Type 2 connections using the old / CLI driver. Currently, WebSphere Application Server and other J2EE servers do not support the IBM Type 3 driver because it does not support distributed transactions (JTA). There will be no enhancements to the Type 3 driver in future releases.
We encourage the use of generic JDBC Type 4 drivers instead of Type 3 drivers.
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 generic JDBC driver is provided in the file db2jcc.jar. Its implementation package is called com.ibm.db2.jcc.DB2Driver.
Note that the generic Type 2 and generic Type 4 drivers have the same implementation class name. There are two ways to tell which driver DB2 will instantiate internally:
Use the connection feature to determine whether the connection uses a shared library (Type 2), or whether the driver initiates a direct connection from the Java application (Type 4).
Use different connection URL modes to indicate which of the Type 2 and Type 4 behaviors you want.
Example of Type 4 URL mode: the string "jdbc:db2://server1:50000/sample" requires the JDBC driver to connect the Java application directly to a database named "sample" on the DB2 server, which is in the DB2 instance configured on the DB2 server (hostname server1), while the DB2 server listens on port 50000.
An example of the Type 2 URL pattern: the string "jdbc:db2:sample". Information about the DB2 server ("server1") and port ("50000") can be found in the DB2 client catalog.
A generic JDBC driver is an abstract JDBC processor that is independent of driver type connectivity or target platform. The generic JDBC driver is an architecture-independent JDBC driver for distributed and local DB2 UDB access. Because the generic JDBC driver is independent of any particular JDBC driver type connectivity or target platform, it supports both Java connectivity (Type 4 driver) and JNI-based connectivity (Type 2 driver) in a single DB2 UDB driver instance. This driver can be used in stand-alone Java applications or multi-tier applications.
Important: in the case of DB2 UDB V8.1.2, the generic JDBC driver requires license JAR files and db2jcc.jar files in CLASSPATH. The following is the required license JAR file:
◆ for Cloudscape ™Network Server V5.1:db2jcc_license_c.jar
◆ for DB2 UDB V8 for Linux, UNIX and Windows servers: db2jcc_license_su.jar
◆ for DB2 UDB for iSeries ®and z/OS server (provided with DB2 Connect and DB2 Enterprise Server Edition): db2jcc_license_cisuz.jar
The universal driver can query the database metadata catalog and retrieve the server error message text by using prerequisite stored procedures that are pre-installed on the target server:
◆ these stored procedures are pre-installed for UDB V8 on Linux, UNIX, and Windows.
◆ for DB2 UDB for OS/390 ®V6, PTF UQ72081 and UQ72082 must be installed.
◆ for DB2 UDB for OS/390 and z/OS V7, PTF UQ72083 must be installed. DB2 UDB V8 on the upcoming z/OS will pre-install the necessary stored procedures.
◆ DB2 UDB for iSeries V5R1 requires PTF SI06308, SI06300, SI06301, SI06302, SI06305, SI06307 and SI05872.
◆ DB2 UDB for iSeries V5R2 requires PTF SI06541, SI06796, SI07557, SI07564, SI07565, SI07566 and SI07567. DB2 UDB for iSeries V5R3 will pre-install the necessary stored procedures.
The Type 4 JDBC driver implementation is shown in figure 4. Note: the generic JDBC/SQLJ drivers (Type 4 and Type 2) used to connect to DB2 for z/OS and OS/390 from the Java application or applet on Linux, UNIX, and Windows require the appropriate license file (db2jcc_license_cisuz.jar). The license file is provided with the DB2 Connect product.
Thank you for your reading, the above is the content of "what is the JDBC driver?" after the study of this article, I believe you have a deeper understanding of what the JDBC driver is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.