Different Types of JDBC Drivers

These days almost no Enterprise Application exist without Database, to store data. And for Java Applications to interact with underlying databases, JDBC Driver is required.

JDBC Driver acts as an interface between Java Application and Database server, as shown in below picture.

JDBC Driver
JDBC Driver

Due to historical reasons there are four different types of JDBC Drivers.

Type 1 JDBC Driver: JDBC-ODBC Bridge driver (Bridge): An ODBC driver uses the Open Database Connectivity (ODBC) interface by Microsoft that allows applications to access data in database management systems (DBMS) using SQL as a standard for accessing the data.  JDBC-ODBC bridge further interacts with ODBC driver, which further interacts with database. These Type of drivers were used during initial versions of Java in 90’s. There is performance hit as JDBC-ODBC bridge causes additional overhead, when Java app interacts with database.

Type 2 JDBC Driver: Native-API/partly Java driver (Native): These drivers again use a Java (JDBC) API, and further interact with local shared libraries in C or C++, which really interact with the Database Server. This approach uses Java Native API feature to interact with C/C++ code. When performance tuning is done in C/C++ libraries there is a chance that Type 2 Drivers can perform similar or better than Type 4.

Type 3 JDBC Driver: AllJava Net-protocol driver (Middleware): Here Java Application send request to Network Proxy Server, which further interacts with Database Server.

Type 4 JDBC Driver: All Java Native-protocol driver (Pure). These type of Driver are completely implemented in Java, and hence they are platform independent. Currently, Type 4 drivers are being widely used. Type 4 Driver for each database are provided by respective Database vendor, as a JAR file. This JAR file need to be added to Java Project, which needs to interact with database. For eg. MySQL  JDBC Driver is provided in below link  MySQL JDBC Driver Download(Jar)
This jar file can be used on any platform.

Reason to have above different types, is due to performance and portability reasons.

Type 1 has worst Performance and Portability, while Type 4 has better Performance and Portability, comparing with other Driver Types.

Currently Type 4 Drivers are used widely.

2 thoughts on “Different Types of JDBC Drivers”

Leave a Reply