Home >>Java JDBC Tutorial >JDBC Driver

JDBC Driver

JDBC Driver

JDBC drivers are the very important part of the language as this is the part that is responsible for implementing the defined interfaces in the JDBC API and that is because for interacting with the user’s database server. The Java.sql package that is responsible for shipping with the JDK consist of various classes along with their behaviors that are defined and their actual implementations are performed in the third-party drivers. Third party vendors generally implement the java.sql.Driver interface in their database driver.

JDBC Drivers Types

The implementations of the JDBC driver varies just as the fact of the wide variety of operating systems and hardware platforms that generally operates in the Java language. Sun, the company that has invented Java has divided the implementation types into majorly four categories that are depicted below:

  • JDBC-ODBC bridge driver
  • JDBC-Native API
  • JDBC-Net pure Java
  • Thin driver or 100% Pure Java

Let's get to know about them one by one

1. JDBC-ODBC bridge driver

In this type of driver, a JDBC Bridge is basically used in order to access the ODBC drivers that are installed on each of the client machine. By using the ODBC there is a requirement of configuring on the user's system a Data Source Name (DSN) that generally used to represent the target database.

This driver had its part of the share of the popularity especially when Java was first released. This driver was a useful driver because of the fact that most of the databases only supported ODBC access but as of now this type of driver is generally recommended only for the experimental use or in the case when there is no other alternative available.

Advantages:

  • This driver is extremely easy to use.
  • This driver can be easily connected to any of the databases.

Disadvantages:

  • The performance of this driver degraded because of the fact that JDBC method call is converted into the ODBC function calls.
  • The ODBC driver generally requires to be installed on the client machine.

2. JDBC-Native API

In this type of driver, the JDBC API calls are generally converted into native C/C++ API calls that are known to be unique to the database. These are those drivers that are typically made available by the database vendors and are used in the exact same manner as the JDBC-ODBC Bridge. Before using this, one thing should be kept in mind that the vendor-specific driver should be installed on each client machine as it is mandatory.

Please note that if the user changes the Database, then the user have to change the native API because it is specific to a database and they are mostly obsolete now. After using this driver the user will experience a speed increase with a Type 2 driver as if the fact that it eliminates ODBC's overhead.

Advantages:

  • This driver's performance has been upgraded than JDBC-ODBC bridge driver.

Disadvantages:

  • This driver in JDBC requires to be installed on each of the client's machine.
  • The Vendor client library also requires to be installed on each of the client's machine.

3. JDBC-Net pure Java

In this type of driver, there is basically a three-tier approach that is used in order to access databases. The JDBC clients are known to use the standard network sockets in order to communicate with a middleware application server. Then the translation of the socket information occurs and the responsibility is of the middleware application server into the call format that is generally required by the DBMS and is forwarded to the database server.

This type of driver is known to be extremely flexible because of the fact that it requires no code to be installed on the client’s system and a single driver is enough to deliver access to the multiple databases.

Advantages:

  • In this driver, there is no requirement of any client side library as the application server can perform various tasks such as load balancing, auditing, logging etc.

Disadvantages:

  • In this driver there is a requirement of network support on the client's machine.
  • This driver requires a database-specific coding that is to be done in the middle tier.
  • This driver's maintenance becomes very costly as this requires database-specific coding to be done in the middle tier.

4. Thin driver or 100% Pure Java

In this type of driver, a pure Java-based driver basically communicates directly with the vendor's database by the help of the socket connection. The performance of this very JDBC driver is known to be the highest performance driver that is available for the database and it is usually delivered by the vendor itself.

This kind of driver is extremely flexible as the user doesn’t need to install the special software on the client’s machine or the server. Another benefit is that these drivers can be downloaded dynamically.

Advantages:

  • In this driver, there is no requirement of any client side library as the application server can perform various tasks such as load balancing, auditing, logging etc.

Advantages:

  • These drivers have a better performance compared to all the other drivers.
  • There is no requirement of any software at the client's side or server's side.

Disadvantages:

  • These drivers generally depend on the Database.

Which Driver should be Used in Which Case?

  • In case the user is accessing one type of database like the Sybase, Oracle, or IBM, then the driver that is most preferred to use is Thin driver or 100% Pure Java.
  • JDBC-Net pure Java is the driver that is to be uses in case the user's Java application is accessing the multiple types of databases all at the same time.
  • JDBC-Native API is the driver that is to be used in case the JDBC-Net pure Java or Thin driver or 100% Pure Java is generally not available yet for the user’s database.
  • JDBC-ODBC bridge driver is basically not considered a deployment-level driver and its major use lies in being typically used only for the development and testing purposes.