Types of JDBC Drivers
JDBC Drivers:
A piece of software known as JDBC Driver permits database communication between Java applications and the server.
In order to communicate with our database server, JDBC drivers put into practice the established interfaces in the JDBC API.
For instance, JDBC drivers allow us to establish database connections and communicate with them by issuing SQL or database instructions and then receiving responses in Java.
The Java.sql package that comes with JDK provides a number of classes with stated behaviours; however, third-party drivers handle the actual implementation of these classes. The java.sql.Driver interface is implemented by third-party suppliers in their database drivers.
A group of Java classes known as a JDBC driver allow us to connect to a certain database.
For instance, the JDBC driver for MySQL will be unique. Many of the JDBC APIs are implemented by a JDBC driver. The real JDBC interfaces are all that are used when our code makes use of a certain JDBC driver. Behind the JDBC interfaces lies the actual JDBC driver in use. As a result, our code won't be aware of a new JDBC driver which we put in.
Types of JDBC Drivers:
There are 4 types of JDBC drivers:
- TYPE 1: JDBC-ODBC bridge driver
- TYPE 2: Native-API driver
- TYPE 3: Network Protocol driver
- TYPE 4: Thin driver
1) JDBC-ODBC Bridge Driver
The JDBC-ODBC bridge driver connects to the database using an ODBC driver. JDBC method calls are transformed into ODBC function calls via the JDBC-ODBC bridge driver. Due to thin drivers, this practice is currently discouraged.
A Java component that converts JDBC interface calls to ODBC calls makes up a type 1 JDBC driver. The database's ODBC driver is then called via an ODBC bridge. When type 4 drivers weren't yet available, type 1 drivers were primarily designed to be utilised at the beginning (all Java drivers).

Advantages:
The fact that the ODBC drivers for the database are already installed on the client's PC makes it easy to use, connect to any database, and access practically any database.
Disadvantages:
Performance suffered as a result of the conversion of JDBC method calls into ODBC function calls.
Since the JDBC call passes through the bridge to the ODBC driver before reaching the native database connection library, this driver's performance is reduced. Through a procedure that is reversed, the outcome is returned.
2) Native API, Partially a Java Driver
The client-side libraries of the database are used by the Native API driver. The driver transforms calls to JDBC methods into native API calls for the database. It is not totally written in Java.
A type 2 JDBC driver is similar to a type 1 driver, except that the ODBC component has been swapped out for a native code component. One particular database product is the focus of the native code portion.

Advantages:
Performance is improved over the JDBC-ODBC bridge driver.
Disadvantage:
Each client PC has to have the Native driver installed.
The client system must have the Vendor client library installed. Type 2 drivers cannot be used for the internet due to this. Drivers of type 2 exhibit poorer performance than those of types 3 and 4.
3) Network Protocol - Pure Java Driver
The vendor-specific database protocol is converted by the network protocol driver's middleware (application server) from JDBC calls, either directly or indirectly. It was written entirely in Java.
An all-Java driver that delivers JDBC interface calls to a central server is known as a type 3 JDBC driver. The JDBC driver then establishes a connection to the database through the intermediate server.

Advantages:
Due to the application server's ability to handle several functions like auditing, load balancing, logging, etc., no client-side library is necessary.
Disadvantages:
Client machines must have network support.
Type 3 drivers need middle-tier database-specific code (in net server). The cost of maintaining the middle-tier server rises.
Due to the middle tier's need for database-specific coding, Network Protocol driver maintenance becomes expensive.
4) Thin driver (or) Native Protocol - Pure Java Driver
Direct conversion of JDBC calls into vendor-specific database protocol is performed by the thin driver. It is called a "thin driver" for this reason. It is entirely written in Java.
An all-Java driver that connects directly to the database is known as a type 4 JDBC driver. It is used for a certain database product. Most JDBC drivers available today are type 4 drivers.

Advantages:
Better performance compared to all other drivers. No specialised software has to be installed on the client (or) server.
Both the client-side and the server-side do not require any software.
Disadvantage:
A driver is reliant on a database.
Type 4 drivers require a distinct driver for each database, according to the user. For instance, we require the Oracle driver to interact with Oracle servers and the Sybase driver to interface with Sybase servers.