JDBC Driver

A JDBC driver is set of software components that help a Java application to interact with database. The JDBC driver implements lots of JDBC classes and interfaces that enable to open connection and interact with database server.

There are 4 types of JDBC drivers:
Type 1 : JDBC-ODBC bridge driver
Type 2 : Native API driver (Partial Java driver)
Type 3 : Network Protocol driver (Pure Java driver for database middleware)
Type 4 : Thin driver (Pure Java driver)

Type 1 : JDBC-ODBC Bridge Driver

  • The JDBC-ODBC is also known as Type 1 driver.
  • The JDBC-ODBC bridge driver converts the JDBC method call into the ODBC function call.
  • The ODBC depends on native libraries of the operating system.
  • This driver is platform dependent.
  • Sun provides the JDBC-ODBC Bridge driver by following URL - “sun.jdbc.odbc.JdbcOdbcDriver”
Advantages
  • It can connect to any database on which ODCB driver is installed.
  • Easy to install and use.
Disadvantages
  • Performance overhead
  • Installed on each client machine
  • Not suitable for applet programming.
Architecture of Type 1 Driver

type one driver

Type 2 : Native API Driver (Partial Java driver)

  • The Native API driver is also known as Type 2 driver.
  • Type 2 driver uses the native code part instead of ODBC parts. It uses the client-side libraries of the database.
  • It is vender specific driver, so must be installed on each client system. This driver converts the JDBC method call into native call of database.
  • The Oracle Call Interface (OCI) driver is an example of a Native API Driver.
Advantages
  • It is faster than type 1 driver.
Disadvantages
  • Type 2 driver is platform dependent.
  • It uses the vendor class libraries, so needs extra installation on client machine.
  • It does not support applet programming.
Architecture of Type 2 Driver

type two driver

Type 3 : Network Protocol Driver

  • It is also known as Type 3 or Pure Java driver for database middleware.
  • The Network protocol driver uses the three-tier model.
  • The middle tier is responsible to converts JDBC calls directly or indirectly into vender specific database protocol.
  • This type of driver is very flexible that is a single driver can actually provide access to multiple databases.
Advantages
  • No need of database vendor library on the client.
  • A single driver can handle any database, provided by the middle tier.
  • It can be used in any web application and no need to install any software on client machine.
Disadvantages
  • It increases the complexity because at middleware we develop the database coding.
  • The client machine must support network protocol.
Architecture of Type 3 Driver

type three driver

Type 4 : Thin driver (Pure Java driver)

  • It is a pure Java driver which connects all Java drivers directly to the vendor specific database protocol.
  • This driver provides the highest performance driver for the database. Thin driver is completely written in Java because of that it is known as 100% pure Java driver.
Advantages
  • It is platform independent means pure Java driver.
  • Performance is very good in comparison to all other drivers.
  • No need of any middleware services.
  • All the processes of application are managed by JVM.
Disadvantages
  • Need a separate driver for each database.
Architecture of Type 4 Driver

type four driver