Advanced Java → JDBC driver types

Innovative Bytes
4 min readFeb 25, 2023

--

JDBC stands for Java DataBase Connectivity. It is a standard Java API (provided by Oracle) that allows Java programs to interact with relational databases. With JDBC, developers can write Java code to connect to a database, send SQL statements, and process the results. JDBC provides a set of classes and interfaces that allow Java programs to access and manipulate data in a database.

JDBC allows Java applications to access databases in a database-independent manner. This means that developers can write a single Java program that can work with different types of databases without having to make any changes to the code. JDBC provides a uniform interface to different types of databases, allowing developers to write database applications that can be easily ported from one database to another.

JDBC also provides support for transaction management, which allows multiple SQL statements to be executed as a single atomic operation. This is useful in situations where multiple SQL statements need to be executed together, such as when transferring funds between bank accounts.

Overall, JDBC is an important component of the Java platform, as it allows Java developers to build powerful database applications that can run on any platform that supports Java.

JDBC drivers are software components that allow Java programs to interact with relational databases using the JDBC API. A JDBC driver provides an implementation of the JDBC API, allowing Java programs to connect to a database, send SQL statements, and process the results.

There are four types of JDBC drivers:

  1. JDBC-ODBC bridge driver: This driver translates JDBC calls into ODBC (Open Database Connectivity) calls and then sends the requests to the ODBC driver installed on the client machine. This type of driver requires the presence of an ODBC driver, which is not available on all platforms.

This is now discouraged because of the thin driver. Oracle does not support the JDBC-ODBC bridge from java 8.

Advantages:

  • Easy to use.
  • Can be easily connected to any database.

Disadvantages:

  • Features are limited and restricted to what the ODBC driver is capable of doing.
  • Platform dependent as it uses ODBC which should be installed in the client system.
  • Does not support JDK 8.

2. Native-API Driver / Native Code Driver: This driver uses a database-specific API to communicate with the database. This type of driver is specific to the database vendor and operating system which requires the presence of native libraries on the client machine. It is not written entirely in java.

Advantages:

  • Good performance when compared to type 1 JDBC driver.

Disadvantages:

  • Client-side libraries need to be installed on the client machine.
  • The driver is platform dependent.
  • Not all database vendors provide client-side libraries.

3. Network protocol driver: This driver communicates directly with the database server using a network protocol. This type of driver is generally more efficient than the other types of drivers and is usually used in client-server applications.

It follows a three-tier communication approach. It can interface with multiple databases which are not vendor specific. The JDBC client driver written in java communicates with a middleware net server using the database-independent protocol, and then this net server translates this request into database commands for that database.

Advantages:

  • No need to install any client-side libraries on client machines.
  • The middleware application server can provide additional functionalities.
  • It is Database independent.

Disadvantages:

  • Requires middleware-specific configurations.
  • May add extra latency (time) as it goes through the middleware server.

4. Thin driver / JDBC driver: This driver is a pure Java implementation of the JDBC API, and communicates directly with the database server using a network protocol. This type of driver does not require any native libraries and is usually used in web applications.

The thin driver converts JDBC calls directly into the vendor-specific database protocol (rules). That is known as a thin driver. It is written in Java Language.

Advantages:

  • Completely written in Java hence it is platform-independent.
  • Provides better performance compared to Type 1 and Type 2 drivers as there is no protocol-specific conversion required.
  • Better than Type 3 as it does not need any middleware application servers.
  • Connects directly to the database drivers.

Disadvantages:

  • Drivers depend on the database.

I hope it helps you. If it is useful to you, you can clap👏 this article and follow me for such articles.

te veo mañana 🤩✨

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Innovative Bytes
Innovative Bytes

Written by Innovative Bytes

AI enthusiast & Flutter developer. Exploring deepfakes, real-time apps, & automation. Blogging about tech innovations, data science, & coding journeys

No responses yet

Write a response