×

JDBC Architecture

JDBC:

JDBC stands for Java Database Connectivity. Sun Microsystems has a specification called JDBC. JDBC is a Java API (Application Programming Interface) that enables users to interact or communicate with different databases.

The JDBC API enable the application to submit the request to the designated database.

We can create the software needed to access databases using JDBC. Accessing databases and spreadsheets is possible via JDBC and the database driver. JDBC API is beneficial for gaining access to business data kept in a relational database (RDB).

The ODBC (Open database connection) driver can provide effective database connectivity, which is necessary for database interaction. This ODBC Driver and JDBC can be used to interact or connect with different types of databases.

Why use JDBC:

The database API used to connect to and run queries on databases prior to JDBC was called ODBC.

However, the ODBC API makes use of the C-based and insecure ODBC driver, which is platform-dependent. Java's own API (JDBC API), which makes use of JDBC drivers, was created for this reason:

  • JDBC assists customers in storing and retrieving data from databases.
  • Clients can update databases via JDBC.

The elements that are employed to establish the connection with the

database using JDBC

  1. JDBC API
  2. JDBC Driver Manager
  3. JDBC-ODBC Bridge

JDBC Architecture:

JDBC Architecture

1. Application: A Java applet or Servlet that connects with a data source is an application in JDBC.

2. JDBC API: JDBC API gives Java applications the classes, methods, and interfaces they need to run SQL queries and get database results. The following list includes some significant classes and interfaces included in JDBC API:

Driver, Connection, Statement, Result-Set, SQL data

Two packages make up the JDBC API:

  • java.sql
  • javax.sql

The initial component of the JDBC API, which application programmers employ, is divided into two components. A database server connection's low-level API is the second component (JDBC Driver).

The java.sql package contains the initial component of the JDBC API. For accessing and processing data stored in a data source (often a relational database) using the Java programming language, we utilise the java.sql package API. The JDBC driver is for the second section (there are four different types of JDBC drivers).  A group of Java classes that implement the JDBC interfaces and are targeted to a particular database are known as JDBC drivers. Standard Java includes the JDBC interfaces. However, the implementation of these interfaces depends on the database we want to connect to. A JDBC driver is the name for such an implementation.

3. Driver Manager: The Driver Manager is crucial in the JDBC design, the Driver Manager is crucial. Enterprise applications are successfully connected to databases via the Driver Manager, which makes use of some database-specific drivers. The Driver Manager class is a part of the Java.sql package as well as the JDBC API. Users and drivers can communicate with one another using the Driver Manager class. It manages to create a link between a database and the proper driver and maintains track of the available drivers. The database driver class may be registered and deregistered as well as a connection between a Java application and the database be established using the methods that are included in it. T

4. JDBC drivers: JDBC drivers enable JDBC-based communication with a data source. A JDBC driver that can converse intelligently with the relevant data source is what we require.

A JDBC driver is an implementation of the JDBC API used to connect to a certain kind of database. There are several JDBC driver types, including:

  • Type 1 - includes a mapping to another data access API; the JDBC-ODBC driver is an illustration of this.
  • Type 2 - sometimes known as a native-API driver - is an implementation that makes use of the target database's client-side libraries.
  • Type 3 - sometimes referred to as a network protocol driver - employs middleware to transform JDBC calls into database-specific calls.
  • Type 4 - connect to a database directly by transforming JDBC calls into database-specific calls, sometimes known as thin drivers or database protocol drivers.

5. Database: Databases like Oracle, SQL etc… are used

JDBC Architecture Types:

JDBC supports both two-tier and three-tier database access processing models.

1. Two - tier architecture

This design enables direct database communication between Java programs. To communicate with a particular database requires a JDBC driver. The user sends a query or request to the database, and the database responds with the results. The database may be found on the same workstation, or any other remote machine linked through a network. This method is known as client-server architecture or configuration.

2. Three - tier architecture

No direct communication exists in this. Requests are sent to the intermediate tier, i.e., a Java program requests an HTML browser, which is subsequently forwarded to the database. The middle tier, which subsequently interacts with the user, receives the request from the database and forwards the response. Both performance and application deployment are made easier.


Related Topics

Memory Areas in Java

Let’s have a look at how memory management in Java works. We will be going to discuss how the objects get destroyed, the working of a garbage collector, and things...

5 minutes read.

Java Pass-by-Reference

In Java, passing parameters can be done using one of two fundamental methods. Pass-by-value is used for the first and pass-by-reference is used for the second. One thing to keep...

2 minutes read.

Java String getBytes() method

getBytes() method returns sequence of bytes. Syntax: There are three variants of getBytes() method: public byte[] getBytes()        public byte[] getBytes(String charsetName) public byte[] getBytes(Charset charset) Returns: It returns sequence of bytes. Java String getBytes() Example...

2 minutes read.

String to JSON in Java

Nowadays, receiving data in JSON String format rather than XML is quite frequent. Java does not transform JSON String to JSON Object when dealing with JSON String. However, using the...

3 minutes read.

Java Math min() Method

The min() method of Math class returns the smaller of two arguments. The arguments can be of double, float, int or long data type. Syntax: public static double min (double a, double...

2 minutes read.

Difference between throw and throws in java

This article shows you the core difference between “throw” and “throws”keywords in Java programming language.The throw keyword tells Java you want another part of the code to deal withthe exception,...

2 minutes read.

BigDecimal toString() in Java

BigDecimal is a Java class that is a part of the java.math package and the java.base module. It implements the ComparableBigDecimal> interface and extends the Number class. The BigDecimal class...

3 minutes read.

Java Boolean logicalAnd() Method

The logicalAnd() method of Java Boolean class returns the result of implementing logicalAND operation on the specified Boolean operands. Syntax:public static boolean logicalAnd (boolean a, boolean b) Parameters:The parameters ‘a’ and ‘b’...

2 minutes read.

Reverse a String using Collections in Java

Generally, a String is a grouping of characters. Yet, in Java, a String is an item that addresses a succession of characters. The Java.lang.String class is utilized to make a...

5 minutes read.

Figurate Number in Java

There have been several uses for figurate or figural numerals throughout history. A number that may be expressed by regular, distinct geometric shapes with spaced evenly points is referred to...

4 minutes read.

What’s New in Java 15

Sealed classes are the new concept that was introduced by Java 15. Sealed classes are a preview feature. Most of the features which are released in java 15 are in...

3 minutes read.

How to Develop Programming Logic in Java?

Introduction In the world of software development, Java programming language is one of the most powerful programming languages that is used to create a wide range of applications. It includes desktop,...

18 minutes read.

Dutch National Flag Problem in Java

Dutch National Flag (DNF) is a programming issue that Edsger Dijkstra put up. The white, red, and blue hues make up the Dutch flag. The goal is to haphazardly set...

6 minutes read.

3N+1 problem program in Java

The 3N+1 problem is a hypothesis in the field of abstract mathematics (not yet proven). Collectively known as the Collatz problem. This tutorial will describe about the 3N+1 problem and...

3 minutes read.

Java Enhanced For Loop (For-each Loop)

JAVA ENHANCED FOR LOOP The enhanced for loop is also called the for-each loop and has some advantages over the regular for loop. A for-each loop is designed to cycle through...

4 minutes read.

How annotations work in Java

Annotations were introduced by sun microsystem and are available from the java 1.5 version. In general, configurations can be done either by XML or by annotations. Hibernate and spring framework users prefer...

4 minutes read.

Static vs Non-Static in Java

A static method can access and update the value of a static data member. The static keyword is mostly used in Java for memory management. The static keyword can be...

6 minutes read.

Producer consumer problem in Java using Synchronised block

The producer-consumer problem in Java, commonly known as the bounded-buffer problem, is a well-known multi-process synchronization challenge where we attempt to synchronize many processes. Two processes are involved in the producer-consumer problem:...

3 minutes read.

Types of Events in Java

One of Java's key ideas is the principle of an event. Events in Java are activities that result in a change in the state or behavior of an object. The...

4 minutes read.

Java Math multiplyFull() Method

The multiplyFull() method of Math class returns the exact product of the arguments. Syntax: public static long multiplyFull (int x, int y) Parameters: The parameters ‘x’ and ‘y’ represent the first value and second...

1 minute read.