What are different types of JDBC Drivers

JDBC allows a Java application to connect to a relational database.

A JDBC driver is a set of Java classes that implement the JDBC interfaces, targeting a specific database. The JDBC interfaces come 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 four types of JDBC drivers. Any java program that works with the database has two parts, the first part is the JDBC API and the second part is the driver that does the actual work.

JDBC Driver Types


  1. JDBC-ODBC Bridge plus ODBC Driver (Type 1): It uses an ODBC driver to connect to the database. We should have ODBC drivers installed to connect to the database, that’s why this driver is almost obsolete.
  2. Native API partly Java technology-enabled driver (Type 2): This driver converts JDBC class to the client API for the database servers. We should have a database client API installed. Because of extra dependency on database client API drivers, this is also not a preferred driver.
  3. Pure Java Driver for Database Middleware (Type 3): This driver sends the JDBC calls to a middleware server that can connect to a different type of database. We should have a middleware server installed to work with this driver. This adds to extra network calls and slow performance and that's why not widely used JDBC driver.
  4. Direct-to-Database Pure Java Driver (Type 4): This driver converts the JDBC calls to the network protocol understood by the database server. This solution is simple and suitable for database connectivity over the network. However for this solution, we should use database-specific drivers, for example, JDBC jars by Oracle for Oracle DB and MySQL Connector/J for MySQL databases.

References

Comments