A JDBC driver is a set of Java classes that implement the JDBC interfaces, targeting a specific database. The JDBC interfaces comes with standard Java, but the implementation of these interfaces is specific to the database you need to connect to. Such an implementation is called a JDBC driver.
There are 4 different types of JDBC drivers:
- Type 1: JDBC-ODBC bridge driver
- Type 2: Java + Native code driver
- Type 3: All Java + Middleware translation driver
- Type 4: All Java driver.
Today, most drivers are type 4 drivers. Nevertheless, I will just discuss the 4 types of drivers shortly.
Type 1 JDBC Driver
A type 1 JDBC driver consists of a Java part that translates the JDBC interface calls to ODBC calls. An ODBC bridge then calls the ODBC driver of the given database. Type 1 drivers are (were) mostly intended to be used in the beginning, when there were no type 4 drivers (all Java drivers). Here is an illustration of how a type 1 JDBC driver is organized:
|Type 1 JDBC driver.|
Type 2 JDBC Driver
A type 2 JDBC driver is like a type 1 driver, except the ODBC part is replaced with a native code part instead. The native code part is targeted at a specific database product. Here is an illustration of a type 2 JDBC driver:
|Type 2 JDBC driver.|
Type 3 JDBC Driver
A type 3 JDBC driver is an all Java driver that sends the JDBC interface calls to an intermediate server. The intermediate server then connects to the database on behalf of the JDBC driver. Here is an illustration of a type 3 JDBC driver:
|Type 3 JDBC driver.|
Type 4 JDBC Driver
A type 4 JDBC driver is an all Java driver which connects directly to the database. It is implemented for a specific database product. Today, most JDBC drivers are type 4 drivers. Here is an illustration of how a type 4 JDBC driver is organized:
|Type 4 JDBC driver.|