Types of Drivers in JDBC

hemantbeast 5,577 views 18 slides Sep 06, 2016
Slide 1
Slide 1 of 18
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18

About This Presentation

Four JDBC Drivers.


Slide Content

Types of D rivers in JDBC Prepared by : Sharma Hemant [email protected]

What is a Driver? A program that controls a device. Every device, whether it be a printer, disk drive, or keyboard, must have a driver program .

What is JDBC Driver? A JDBC driver is a software component enabling a Java application to interact with a database server. For example, using JDBC drivers enable you to open database connections and to interact with it by sending SQL or database commands then receiving results with Java .

Types of JDBC Driver JDBC driver implementations vary because of the wide variety of operating systems and hardware platforms in which Java operates. Sun has divided the implementation types into four categories, Types 1, 2, 3, and 4, which is below JDBC-ODBC Bridge Driver Native-API driver Network-Protocol driver (middleware driver) Database-Protocol driver (Pure Java driver )

Type 1: JDBC-ODBC Bridge Driver The JDBC-ODBC bridge driver uses ODBC driver to connect to the database. The JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function calls . The JDBC-ODBC Bridge that comes with JDK 1.2 is a good example of this kind of driver . Sun provided a JDBC-ODBC Bridge driver: sun.jdbc.odbc.JdbcOdbcDriver.

Type 1: JDBC-ODBC Bridge Driver

Type 1: JDBC-ODBC Bridge Driver Advantages: easy to use. can be easily connected to any database . Disadvantages : Performance degraded because JDBC method call is converted into the ODBC function calls. The ODBC driver needs to be installed on the client machine.

Type 2: JDBC-Native API Driver The Native API driver uses the client-side libraries of the database. The driver converts JDBC method calls into native C/C++ API calls, which are unique to the database. It is not written entirely in java . The Oracle Call Interface (OCI) driver is an example of a Type 2 driver.

Type 2: JDBC-Native API Driver

Type 2: JDBC-Native API Driver Advantage: performance upgraded than JDBC-ODBC bridge driver . Disadvantage: The Native driver needs to be installed on the each client machine. The Vendor client library needs to be installed on client machine .

Type 3 : Network-Protocol driver The Network Protocol driver uses middleware (application server) that converts JDBC calls directly or indirectly into the vendor-specific database protocol. It is fully written in java . This kind of driver is extremely flexible, since it requires no code installed on the client and a single driver can actually provide access to multiple databases . Your application server might use a Type 1, 2, or 4 driver to communicate with the database, understanding the nuances will prove helpful.

Type 3: Network-Protocol driver

Type 3: Network-Protocol driver Advantage: No client side library is required because of application server that can perform many tasks like auditing, load balancing, logging etc. Disadvantages: Network support is required on client machine. Requires database-specific coding to be done in the middle tier. Maintenance of Network Protocol driver becomes costly because it requires database-specific coding to be done in the middle tier .

Type 4: Database-Protocol driver In a Type 4 driver, a pure Java-based driver communicates directly with the vendor's database through socket connection. This is the highest performance driver available for the database and is usually provided by the vendor itself . This kind of driver is extremely flexible, you don't need to install special software on the client or server. Further, these drivers can be downloaded dynamically . MySQL's Connector/J driver is a Type 4 driver. Because of the proprietary nature of their network protocols, database vendors usually supply type 4 drivers.

Type 4: Database-Protocol driver

Type 4: Database-Protocol driver Advantage: Better performance than all other drivers. No software is required at client side or server side . Disadvantage: Drivers depends on the Database .

Architecture of JDBC Driver

Thank You The End.