×

Types of JDBC Drivers

JDBC Drivers:

A piece of software known as JDBC Driver permits database communication between Java applications and the server.

In order to communicate with our database server, JDBC drivers put into practice the established interfaces in the JDBC API.

For instance, JDBC drivers allow us to establish database connections and communicate with them by issuing SQL or database instructions and then receiving responses in Java.

The Java.sql package that comes with JDK provides a number of classes with stated behaviours; however, third-party drivers handle the actual implementation of these classes. The java.sql.Driver interface is implemented by third-party suppliers in their database drivers.

A group of Java classes known as a JDBC driver allow us to connect to a certain database.

For instance, the JDBC driver for MySQL will be unique. Many of the JDBC APIs are implemented by a JDBC driver. The real JDBC interfaces are all that are used when our code makes use of a certain JDBC driver. Behind the JDBC interfaces lies the actual JDBC driver in use. As a result, our code won't be aware of a new JDBC driver which we put in.

Types of JDBC Drivers:

There are 4 types of JDBC drivers:

  • TYPE 1: JDBC-ODBC bridge driver
  • TYPE 2: Native-API driver
  • TYPE 3: Network Protocol driver
  • TYPE 4: Thin driver

1) JDBC-ODBC Bridge Driver

The JDBC-ODBC bridge driver connects to the database using an ODBC driver. JDBC method calls are transformed into ODBC function calls via the JDBC-ODBC bridge driver. Due to thin drivers, this practice is currently discouraged.

A Java component that converts JDBC interface calls to ODBC calls makes up a type 1 JDBC driver. The database's ODBC driver is then called via an ODBC bridge. When type 4 drivers weren't yet available, type 1 drivers were primarily designed to be utilised at the beginning (all Java drivers).

Types of JDBC Drivers

Advantages:

The fact that the ODBC drivers for the database are already installed on the client's PC makes it easy to use, connect to any database, and access practically any database.

Disadvantages:

Performance suffered as a result of the conversion of JDBC method calls into ODBC function calls.

Since the JDBC call passes through the bridge to the ODBC driver before reaching the native database connection library, this driver's performance is reduced. Through a procedure that is reversed, the outcome is returned.

2) Native API, Partially a Java Driver

The client-side libraries of the database are used by the Native API driver. The driver transforms calls to JDBC methods into native API calls for the database. It is not totally written in Java.

A type 2 JDBC driver is similar to a type 1 driver, except that the ODBC component has been swapped out for a native code component. One particular database product is the focus of the native code portion.

Types of JDBC Drivers

Advantages:

Performance is improved over the JDBC-ODBC bridge driver.

Disadvantage:

Each client PC has to have the Native driver installed.

The client system must have the Vendor client library installed. Type 2 drivers cannot be used for the internet due to this. Drivers of type 2 exhibit poorer performance than those of types 3 and 4.

3) Network Protocol - Pure Java Driver

The vendor-specific database protocol is converted by the network protocol driver's middleware (application server) from JDBC calls, either directly or indirectly. It was written entirely in Java.

An all-Java driver that delivers JDBC interface calls to a central server is known as a type 3 JDBC driver. The JDBC driver then establishes a connection to the database through the intermediate server.

Types of JDBC Drivers

Advantages:

Due to the application server's ability to handle several functions like auditing, load balancing, logging, etc., no client-side library is necessary.

Disadvantages:

Client machines must have network support.

Type 3 drivers need middle-tier database-specific code (in net server). The cost of maintaining the middle-tier server rises.

Due to the middle tier's need for database-specific coding, Network Protocol driver maintenance becomes expensive.

4) Thin driver (or) Native Protocol - Pure Java Driver

Direct conversion of JDBC calls into vendor-specific database protocol is performed by the thin driver. It is called a "thin driver" for this reason. It is entirely written in Java.

An all-Java driver that connects directly to the database is known as a type 4 JDBC driver. It is used for a certain database product. Most JDBC drivers available today are type 4 drivers.

Types of JDBC Drivers

Advantages:

Better performance compared to all other drivers. No specialised software has to be installed on the client (or) server.

Both the client-side and the server-side do not require any software.

Disadvantage:

A driver is reliant on a database.

Type 4 drivers require a distinct driver for each database, according to the user. For instance, we require the Oracle driver to interact with Oracle servers and the Sybase driver to interface with Sybase servers.


Related Topics

Java Console

If there is a character-based console device connected to the active Java virtual machine, it can be accessed using methods provided by the Java.io.Console class. JDK 6 adds the Console...

3 minutes read.

Prime Points in Java

The points that divide an integer into two halves containing a prime number are known as prime points. Printing every prime point of a specific number is the task. Let's...

6 minutes read.

What is advance Java?

The definition of advance inside the dictionary refers to a forward motion, development, or progress, and the definition of enhancing is something that improves things. To become experts in that...

3 minutes read.

Java Math nextUp() Method

The nextUp() method of Math class returns the floating-point number adjacent to the argument in direction of the positive infinity. Syntax: public static double nextUp (double d)public static float nextUp (float f) Parameters: The...

2 minutes read.

Annotations in Java

Annotations in Java Java Annotations are metadata about the source code. They do not have any direct effect on the execution of the java program. Annotations in Java were introduced in...

4 minutes read.

Java 9 Tutorial

The Java 9 is most popular release of java programming to make it platform modular. It is used to improve JDK and java implementation security. It provides JAVA SE and...

3 minutes read.

Implementing Queue Using Array in Java

We can implement queue by using array in Java. The queue is a linear data structure, and the array is one of the simplest data structures. Before implementing a queue...

4 minutes read.

Star Program in Java

By solving the patterns, we can develop our coding skills and logical thinking. Mostly each pattern program uses two or more loops. Loops' number depends on the complexity of logic....

3 minutes read.

Java Swing

Java Swing is the extension of Abstract Windows Toolkit (AWT). Any component designed in Swing will appear the same on any platform. Problems/Disadvantage of Abstract Windows Toolkit (AWT): As we know that...

27 minutes read.

Java SHA256

Definition: In cryptography, SHA is a hash function that takes 20 bytes of input and produces an approximate 40-digit hexadecimal integer as the hash result. Class for Message Digest: Java's MessageDigest Class,...

2 minutes read.

Counting sort in Java

An array's elements are sorted using the counting sort method, which counts how many times each distinct element appears in the array. The count is kept in an auxiliary array,...

3 minutes read.

Difference between this and super in Java

In this article, you will be very well equipped with the knowledge of this keyword and super keyword in java. You will be able to understand where to implement this...

3 minutes read.

Java Command Line Argument

Command-line arguments are passed to the main() method when we want to pass information into a program during runtime. It is the information that directly follows the program’s name on the...

1 minute read.

Java Queue Interface

Queue interface is a subtype of Collection interface. All methods in the Collection interface are also available in the Queue interface. It provides operations of Collection and also some additional...

2 minutes read.

Java Map Generic

Java arrays maintain an ordered collection of things, and the index can be used to access the data (an integer). Unlike HashMap, which stores data as a Key/Value pair. We...

3 minutes read.

How to Convert long to String in Java

How to Convert long to String in java It is used if we have to display a long number in the text field because everything is displayed as a String. A...

3 minutes read.

Java Class Keyword

We know that java is object-oriented programming language which contains the essential key concepts such as classes and objects etc to have clear idea about the object-oriented programming.Java is mainly...

3 minutes read.

Java Public Keyword

A Java access modifier is a public keyword. It can be applied to classes, constructors, methods, and variables. It is the type of access modifier that is least constrained. A...

4 minutes read.

Deadlock Prevention and avoidance in Java

This tutorial will discuss deadlock prevention and Avoidance in Java programming language. Introduction Multithreading in Java includes deadlock. We can multitask by running several threads concurrently in the multithreading environment. Deadlock occurs...

4 minutes read.

Palindrome number program in Java

Write java program to check if a number is palindrome in Java? A number that does not change on reversing is called a palindrome number. In other words, when reversing the...

3 minutes read.