Quantcast
Channel: Tech Tutorials
Viewing all articles
Browse latest Browse all 885

Types of JDBC Drivers

$
0
0

JDBC driver is an implementation of the Driverinterface in the java.sqlpackage.

Every database vendor should provide a JDBC driver for their DBMS and each JDBC driver should supply a class that implements the Driver interface.

There are many possible implementations of JDBC driver, these implementations can be categorized into four types.

  • Type 1 driver
  • Type 2 driver
  • Type 3 driver
  • Type 4 driver

Type 1 Driver

Type 1 driver is a type of JDBC driver that implements the JDBC API as a mapping to another DB access API.

As example - The JDBC-ODBC Bridge driver that maps JDBC API requests to ODBC requests. Here note that ODBC (Open Database Connectivity) is another standard API for accessing databases which is developed by Microsoft.

Type 1 drivers type are generally dependent on a native library, which limits their portability.

DB access through Type 1 driver

Type 2 Driver

Type 2 drivers are written partly in Java and partly in native code. Native client library specific to the data source to which connection is made is used by Type 2 JDBC drivers.

As example - Oracle's OCI (Oracle Call Interface) client-side driver is an example of a Type 2 driver.

Since native code is used by Type 2 drivers, their portability is limited.

DB access through Type 2 driver

Type 3 Driver

Type 3 driver has a client that is written in Java and that connects to a middleware server using a database independent protocol. Middleware server in turn communicates with the data source.

The drawback of Type 3 driver is that the middleware server has to be DB specific.

There are two stages in Type 3 driver. First, where Java application connects to Type 3 driver which in turn connects to middleware server. Its the sever which translates the request to DB specific request making the whole process slower.

DB access through Type 3 driver

Type 4 Driver

Type 4 drivers are written completely in Java so no native code library or middleware server is needed, that is why type 4 drivers are also known as thin drivers. Type 4 drivers themselves implement the network protocol for a specific data source.

DB access through Type 4 driver

Reference : https://docs.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html

That's all for this topic Types of JDBC Drivers. If you have any doubt or any suggestions to make please drop a comment. Thanks!


Related Topics

  1. Java JDBC overview - JDBC Tutorial
  2. Java JDBC Steps to Connect to DB
  3. Data access in Spring framework

You may also like -

>>>Go to Java advance topics page


Viewing all articles
Browse latest Browse all 885

Trending Articles