JDBC Driver Types

JDBC (Java Database Connectivity) is a standard API (Application Programming Interface) for connecting Java applications to databases. There are four types of JDBC driver architecture which are listed below:

  1. Type 1: JDBC-ODBC Bridge driver
  2. Type 2: Native API partly Java driver
  3. Type 3: Network Protocol driver
  4. Type 4: Native Protocol driver

Type 1: JDBC-ODBC Bridge driver

This driver uses an ODBC (Open Database Connectivity) driver to connect to the database. It is a bridge between the JDBC API and the ODBC API. It provides a generic interface to connect to any database that has an ODBC driver. The driver is platform dependent and requires an ODBC driver to be installed on the client machine. This driver is not recommended for production environments.

Type 2: Native API partly Java driver

This driver converts JDBC calls to the native API of the database. It provides better performance than the Type 1 driver, as it eliminates the need for the ODBC layer. It is also platform dependent and requires native code to be installed on the client machine.

Type 3: Network Protocol driver

This driver uses a middleware server to communicate with the database. It converts JDBC calls to a database-specific network protocol, which is then sent to the middleware server. The middleware server translates the protocol to the database-specific protocol and sends it to the database. It provides better portability than the Type 1 and Type 2 drivers, as it eliminates the need for database-specific code on the client machine.

Type 4: Native Protocol driver

This driver communicates directly with the database using a database-specific protocol. It is a pure Java driver. This means, it is a platform independent and does not require any native code to be installed on the client machine. It provides better performance than the Type 3 driver, as it eliminates the need for the middleware server. It is the recommended driver for production environments.

References:

  • https://en.wikipedia.org/wiki/JDBC_driver
  • https://docs.oracle.com/cd/A97335_02/apps.102/a83724/overvw2.htm