JDBC Drivers

A JDBC Driver is a software component that enables a Java application to communicate with a specific database. It acts as a bridge between the JDBC API and the database by converting JDBC calls into database-specific commands. Different databases may require different JDBC drivers.

Types of JDBC Drivers:

There are four types of JDBC drivers:

  1. Type 1 – JDBC-ODBC Bridge Driver
  2. Type 2 – Native-API Driver
  3. Type 3 – Network Protocol Driver
  4. Type 4 – Thin / Pure Java Driver

1. JDBC-ODBC Bridge Driver

The JDBC-ODBC Bridge Driver converts JDBC calls into ODBC calls. It uses an ODBC driver as an intermediate layer to communicate with the database.

Type-1 Driver

  • The Java application sends database requests through the JDBC API.
  • The Type 1 driver converts JDBC calls into ODBC calls.
  • The ODBC driver communicates with the database.
  • It requires ODBC to be installed on the client machine.
  • It is platform-dependent and has lower performance.
  • It is obsolete and not recommended for modern applications.

2. Native-API Driver

The Native-API Driver converts JDBC calls into database-specific native API calls. It uses native libraries provided by the database vendor.

Type-2 Driver

  • The Java application sends requests through the JDBC API.
  • The Type 2 driver converts JDBC calls into native database API calls.
  • The native API communicates with the database.
  • Database-specific native libraries must be installed on the client system.
  • It can provide better performance than Type 1.
  • It is platform-dependent because it requires native libraries.

3. Network Protocol Driver

The Network Protocol Driver converts JDBC calls into a database-independent network protocol. It communicates with a middleware server that connects to the database.

Type-3 Driver

  • The Java application sends JDBC requests to the Type 3 driver.
  • The driver converts the requests into a database-independent network protocol.
  • The request is sent to a middleware server.
  • The middleware server converts the request into a database-specific protocol.
  • The middleware server communicates with the database.
  • It can support multiple types of databases.

4. Thin Driver / Pure Java Driver

The Thin Driver / Pure Java Driver is a pure Java driver that converts JDBC calls directly into the database-specific network protocol. It communicates directly with the database without requiring ODBC, native libraries, or middleware.

Type-4 Driver

  • The Java application sends requests through the JDBC API.
  • The Type 4 driver directly converts JDBC calls into the database-specific protocol.
  • It communicates directly with the database.
  • It does not require ODBC or native database libraries.
  • It is platform-independent because it is written completely in Java.
  • It provides good performance and is the most commonly used type of JDBC driver today.
Scroll to Top