While communicating with the database, we have to convert Java calls into database-specific calls and database-specific calls into Java calls. To do this task, we require the JDBC Driver.

The JDBC Driver is one of the most crucial parts of the entire JDBC. The JDBC Driver is a software component that enables a Java application to interact with a database.
The important functionalities of the JDBC driver are:
- It handles the communication with the database server.
- Instead of directly creating a Driver object, we use the DriverManager object to deal with the Drivers.
- It also abstracts the details associated with working with the Driver objects.
Types of JDBC Driver
Based on the functionality and the architecture, all the Drivers are classified into four types:
- Type-1 Driver or JDBC-ODBC bridge driver
- Type-2 Driver or Native-API driver
- Type-3 Driver or Network Protocol driver
- Type-4 Driver or Pure Java Direct-to-Database or Thin Driver
Let us now see each of these types in detail.
Type 1 - JDBC-ODBC Bridge Driver
The Type-1 Driver converts JDBC calls into ODBC calls, and ODBC Driver converts the ODBC calls into the database-specific calls. Open Database Connectivity (ODBC) is an open standard Application Programming Interface (API) for accessing a database.ODBC is platform dependent as we can use ODBC only for windows platform. Internally the Type-1 Driver takes the support of the ODBC Driver to communicate with the database. The Type-1 Driver is provided by the Sun microsystems as part of the JDK. The figure below shows the architecture of the Type-1 Driver.
From the figure above, we can see how the Type-1 Driver acts as a bridge between the JDBC and ODBC Driver. Because of this, the Type-1 Driver is also known as the JDBC-ODBC Bridge Driver or simply the Bridge Driver.
Advantages of JDBC-ODBC Bridge Driver
- It is easy to use and maintain.
- We do not have to separately install the Type-1 Driver because it is available as part of the JDK.
- The Type-1 Driver is database-independent. Type-1 Driver does not communicate with the database directly. Instead, the ODBC Driver does this work.
- Migrating from one database to another is easy as it is database-independent.
Disadvantage of JDBC-ODBC Bridge Driver
- It is the slowest Driver among all the Drivers because first, it converts the JDBC calls into the ODBC calls, and then the ODBC Driver converts the ODBC calls into the database-specific calls. This makes the overall process slow.
- The ODBC Driver is available for the Windows platform only. The Type-1 Driver depends internally on the ODBC Driver; hence it is platform dependent.
- No support from JDK 1.8 onwards.
Type 2 - Native-API Driver
The architecture of the Type-2 Driver is similar to the Type-1 Driver. However, instead of an ODBC Driver, we have vendor-provided database-specific libraries that can be understood by the database directly. Hence the calls made by the Java application are converted into database-specific native library calls by the Type-2 Driver. The database-specific native library call can be understood by the database because it is provided by the database vendor. The architecture of the Type-2 Driver is shown below.
This Driver is also known as the native API Driver because it internally uses the database-specific native libraries. In order to use the Driver, we have to install the vendor-provided native libraries on the client machine or system.
Also see, Duck Number in Java and Hashcode Method in Java
Advantages of Native-API Driver
- It is faster as compared to the Type-1 Driver because it converts the function calls only once.
- ODBC Driver not required.
- It provides more portability.
Disadvantages of Native-API Driver
- It is a database-dependent Driver since it internally uses database-specific native libraries to interact with the database. Therefore migrating from one database to another is difficult.
- It is platform-dependent too.
- We have to mandatorily install the native libraries on the client machine or system.
Type 3 - Network Protocol Driver
The Type-3 Driver is also known as the network protocol Driver or middleware Driver. The middleware server is responsible for converting the JDBC calls into vendor-specific database calls.
The architecture of Type-3 Driver is shown below:
Advantages of Network Protocol Driver
- It is database-independent.
- It is platform-independent as it is written in Java.
- The application server performs the necessary tasks; therefore, the client-side library is not required.
Disadvantages of Network Protocol Driver
- It is expensive because of the maintenance of the network protocol Driver.
- We need network support on the client machine.
Type 4 - Pure Java Direct-to-Database or Thin Driver
Unlike the previous three types of Drivers, the Type-4 Driver does not require any extra component to communicate with the database. It can directly communicate with the database.
The architecture of the Type-4 Driver is shown below:
The type-4 Driver is also known as pure Java Driver because it is completely written in Java. This makes it platform-independent. It communicates with the database using the native protocol provided by the database vendor, and therefore it is also known as a native protocol Driver. It is also referred to as a thin Driver.
Advantages of Pure Java Direct-to-Database or Thin Driver
- It is platform-independent.
- Since it communicates with the database directly, the overall performance is improved and faster.
- It does not require any native libraries or middleware servers.
Disadvantages of Pure Java Direct-to-Database or Thin Driver
- It is database-dependent.
You can also use online java compiler for compile and run the code for good practice.
Frequently Asked Questions
Why is JDBC used?
JDBC (Java Database Connectivity) is used to enable Java applications to interact with a wide range of databases. It provides a standardized API for executing SQL statements, managing connections, and retrieving results.
What Type of JDBC Driver Should You Use?
The choice of JDBC driver depends on the specific requirements of your application, such as performance needs, database type, and network architecture. Common types include Type 4 (pure Java drivers) for direct database connections.
What is a JDBC Driver?
A JDBC driver is a software component that allows Java applications to connect to a database. It translates Java calls into database-specific calls, facilitating communication between the application and the database server.
Which JDBC Driver is both database and platform-independent?
The Type-3 Driver. It is also known as the Network Protocol Driver.
Which Driver is the slowest?
Type-1 Driver is the slowest.
Which Driver is preferred while accessing multiple databases?
The type-3 Driver because Type-3 drivers are fully written in Java, hence they are portable drivers. No client side library is required because of the application server that can perform many tasks like auditing, load balancing, logging etc.