JDBC Drivers in Java

JDBC Drivers in Java are responsible for making transactions  with Database from a Java application , along with JDBC API. The JDBC driver establishes connection with relational database .

JDBC Drivers in Java

There are four types of JDBC drivers available

1)Type 1 Driver (JDBC-ODBC Bridge Driver)

2)Type 2 Driver (Native API Driver)

3)Type 3 Driver(Network Protocol Driver)

4)Type 4 Driver(Native protocol Driver or Pure Java Driver)

We are going to see all four types of drivers in detail.

1)Type 1 Driver(JDBC-ODBC Driver)

This type of driver converts JDBC calls to ODBC calls. And transfers the calls to the pre-installed  ODBC drivers. ODBC is the acronym for Open Data Base Connectivity(It is an API for database connectivity written in C programming  language). This type of driver  is platform dependent .ODBC driver directly uses the native libraries of the underlying Operating System.

JDBC - ODBC BRIDGE  DRIVER

Advantages of  type 1 driver

1)Any data base for which ODBC driver is installed ,can be supported

Disadvantages of type 1 Driver

1)Performance is slow because of JDBC-ODBC bridge

2)ODBC driver should be installed for using the type 1 driver.

2)Type 2 Driver (Native API Driver)

This type of driver uses the native libraries of the data base. So type 2 driver converts  JDBC calls to native API calls of the connected database.

Advantages of type 2 driver

1)Faster than type 1 driver

Disadvantages of type 2 driver 

1)It is Platform dependent.

2)If native library is not there for a database , then this driver has no use

3)Type 3 Driver (Network Protocol Driver)

This type of driver is using  a middle tier  for communicating with data base. The middle tier converts the JDBC calls to vendor specific data base calls. The driver is communicating  with the  middle tier.

Advantages of type 3 driver

1)Single driver can support any data base which the middle tier supports.

2)Middle ware services like caching , logging etc can be done.

Disadvantages of type 3 driver

1)Data base specific logic should be there in middle tier.

4)Type 4 Driver

It is the pure Java driver.It does not need any support from middle ware or native APIs of  data base. It converts database calls to vendor specific database protocol calls. It is platform independent too.As we know , the database protocol for each database is vendor specific . So for connecting with different databases , vendor specific drivers needs to be used. In other words type4 driver for MySQL cannot be used for MSSQL Server.

Advantages

1)Platform independent

2)Faster

Disadvantages

1)Vendor specific drivers needs to be used for each type of data base.

See related topics:

JDBC fundamentals

Database read in Java

Database insert in Java

Database update in Java

PreparedStatement in Java

Leave a Reply

Your email address will not be published. Required fields are marked *