JDBC Drivers

JDBC Drivers

The different types of drivers available in JDBC are listed below:

JDBC Driver Types Description
Type-1 Driver Referes to Bridge Driver (JDBC-ODBC bridge)
Type-2 Driver Referes to a party java and partly native code driver (Native-API partly java driver)
Type-3 Driver Referes to pure java driver that uses a middleware driver to connect to a database (pure java driver for database middleware)
Type-4 Driver Referes to a pure java driver (pure), which is directly connected to a database

Now let’s discuss each of these drivers in detail.

Type-1 Driver

The Type-1 driver acts as a bridge between JDBC and other database connectivity mechanisms, like ODBC. An example of this type of driver is the Sun JDBC-ODBC bridge driver, which provides access to the database through the ODBC drivers. This driver also helps the Java programmers to use JDBC and develop Java applications to communicate with existing data sources. This driver is included within the Java2 SDK within the sun.jdbc.odbc package.

JDBC Driver Type 1

The above figure shows the architecture of the system that uses the JDBC-ODBC bridge driver to communicate with the respective database. In the above figure, SP API refers to the APIS used to make a Native DBMS specific call. Above figure shows the following steps that are involved in establishing a connection between a Java application and data source through the Type-1 driver:

  1. The Java application makes the JDBC call to the JDBC-ODBC bridge driver to access a data source.
  2. The JDBC-ODBC bridge driver resolves the JDBC call and makes an equivalent ODBC call to the ODBC driver.
  3. The ODBC driver completes the request and sends responses to the JDBC-ODBC bridge driver.
  4. The JDBC-ODBC bridge driver converts the response into JDBC standards and displays the result to the requesting Java application.

The Type-1 driver is generally used in the development and testing phases of Java applications.


  • Represents single driver implementation to interact with different data sources
  • Allows you to communicate with all the databases supported by the ODBC driver
  • Represents a vendor independent driver


  • Decreases the execution speed due to a large number of translations
  • Depends on the ODBC driver, and thus, Java applications also become indirectly hooked into ODBC drivers
  • Requires the ODBC binary code or ODBC client library that must be installed on every client
  • Uses Java Native Interface (JNI) to make ODBC calls

The preceding disadvantages make the Type-l driver unsuitable for the production environment and should be used only in the case where no other driver is available. The Type-1 driver is also not recommended when Java applications are required with auto-installation applications, such as applets.

Type-2 Driver (Java to Native API)

Type-2 Driver (Java to Native API) The JDBC call can be converted into the database vendor-specific native call with the help of the Type-2 driver. In other words, this sort of driver makes Java Native Interface (JNI) calls on database-specific native client API. These database-specific native client APIs are usually written in C and C++.

Native-API partly java driver

As shown above figure, the Java application that needs to communicate with the database is programmed using the JDBC API. These JDBC calls (programs written by using JDBC API) are converted into database-specific native calls in the client machine and therefore the request is then dispatched to the database-specific native libraries. These native libraries present in the client are intelligent enough to send the request to the database server by using a native protocol.

This type of driver is implemented for a specific database and usually delivered by a DBMS vendor. However, it’s not mandatory that Type-2 drivers need to be implemented by DBMS vendors only. An example of a Type-2 driver is the Weblogic driver implemented by BEA Weblogic. Type-2 drivers can be used with server-side applications.


  • Helps to access the data faster as compared to other types of drivers
  • Contains additional features provided by the specific database vendor, which are also supported by the JDBC specification


  • Requires native libraries to be installed on client machines since the conversion from JDBC calls to database-specific native calls is done on client machines
  • Executes the database-specific native functions on the client JVM, implying that any bug in the Type-2 driver might crash the JVM
  • Increases the cost of the application in case it is run on different platforms


  • OCI (Oracle Call Interface) Driver: Communicates with the Oracle database server. This driver converts JDBC calls into Oracle native library) calls.
  • Weblogic OCI Driver for Oracle: Makes JNI calls to Weblogic library functions. The Weblogic OCI driver for Oracle is similar to the Oracle OCI driver.
  • Type-2 Driver for Sybase: Converts JDBC calls into Sybase dblib or ctlib calls, which are native libraries to connect to Sybase.

Type-3 Driver (Java to Network Protocol/All Java Driver)

The Type-3 driver translates the JDBC calls into a database server independent and middleware server-specific calls. With the help of the middleware server, the translated JDBC calls are further translated into database server specific calls.

JDBC Driver Type 3

As shown in the above figure, a JDBC Type-3 driver listens for JDBC calls from the Java application and translates them into middleware server-specific calls. After that, the driver communicates with the middleware server over a socket. These types of drivers are also known as net-protocol fully Java technology-enabled or net protocol drivers.

The middleware server is often added in an application with some additional functionality, like pool management, performance improvement, and connection availability. These functionalities make the Type-3 driver architecture more useful in enterprise applications. The type-3 driver is recommended to be used with applets since this type of driver is auto downloadable.


  • Serves as a Java driver and is auto downloadable.
  • Does not require any native library to be installed on the client machine.
  • Ensures database independence, because a single driver provides access to different types of databases.
  • Does not provide the database details, such as username, password, and database server location, to the client. These details are automatically configured in the middleware server.
  • Provides the facility to switch over from one database to another without changing the client-side driver classes. Switching of databases can be implemented by changing the configurations of the middleware server.


The main disadvantage of the Type-3 driver is that it performs the tasks slowly due to the increased number of network calls as compared to Type-2 drivers. In addition, the Type-3 driver is also costlier as compared to other drivers.


  • IDS Driver: Listens for JDBC calls and converts them into IDS Server-specific network calls. The Type-3 driver communicates over a socket to IDS Server, which acts as a middleware server.
  • Weblogic RMI Driver: Listens for JDBC calls and sends the requests from the client to the middleware server by using the RMI protocol. The middleware server uses an appropriate JDBC driver to speak with a database.

Type-4 Driver (Java to Database Protocol)

Type-4 Driver (Java to Database Protocol) The Type-4 driver may be a pure Java driver, which implements the database protocol to interact directly with a database. This type of driver does not require any native database library to retrieve the records from the database. In addition, the Type-4 driver translates JDBC calls into database specific network calls.

JDBC Driver Type 4

As shown in the above figure, the Type-4 driver prepares a DBMS specific network message and then communicates with the database server over a socket. This type of driver is lightweight and generally known as a thin driver. The Type-4 driver uses database-specific proprietary protocols for communication. Generally, this type of driver is implemented by DBMS vendors, since the protocols used are proprietary.

You can use the Type-4 driver when you want an auto downloadable option for the client-side applications, in addition, it can be used with server-side applications.


  • Serves as a pure Java driver and is auto downloadable
  • Does not require any native library to be installed on the client machine
  • Uses database server specific protocol
  • Does not require a middleware server


The main disadvantage of the Type-4 driver is that it uses database specific proprietary protocol and is DBMS vendor dependent.


  • Thin Driver for Oracle from Oracle Corporation
  • Weblogic and MSSQLServer4 for MS SQL server from BEA systems.

Learn more about Hibernate in java

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.