JDBC Driver Types
A JDBC driver can be fall into one of the 4 types: Type 1, Type 2, Type 3, and Type 4. The different types of JDBC drivers are mentioned below—
- JDBC-ODBC Bridge driver [Type 1 Driver]
- Native-API Partly-Java driver [Type 2 Driver]
- Network Protocol Pure-Java driver [Type 3 Driver]
- Native Protocol Pure-Java driver [Type 4 Driver]
Each of the types is briefly discussed in the following segments:
1) JDBC-ODBC Bridge driver converts JDBC calls to Open Database Connectivity (ODBC) calls. This data access method requires that the ODBC drivers be installed on the client machines.
2) Native-API Partly-Java driver converts JDBC calls into calls in the native DBMS protocol. Since this conversion takes place on the client side, some binary code must be installed on the client machine. Type 2 drivers are drivers written in part Java and part native API (C or C++) to convert JDBC calls into calls on the client API for Oracle, MySQL, DB2, or other RDBMS.
3) Network Protocol Pure-Java driver converts JDBC calls into a net protocol that is independent of any native DBMS protocol. Then, middle-ware software running on a server converts the net protocol to the native DBMS protocol. Since this conversion takes place on the server side, no installation is required on the client machine.
4) Native Protocol Pure-Java driver converts JDBC calls into a native DBMS protocol. Since this conversion takes place on the server side, no installation is required on the client machine. Some of the Type 4 drivers for various databases are MySQL, Oracle, MS SQL Server, and DB2.
The following figure shows the working of the all 4 driver types together.
Figure 1: JDBC Driver Types
Not all JDBC drivers are created equal. Some are fast and some are slow. Slower drivers are not necessarily inefficient code. Some drivers are slower than others due to their architectural limitation.