×

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

Java Boolean getBoolean() Method

The getBoolean() method of Java Boolean class returns true if the specified system property is not null and is equal to the String ‘true’, else the result returned is false. Syntax public...

1 minute read.

GCD of Different SubSequences in Java

The positive numbers are provided in an array called inArr. The aim is to determine the number of distinct GCDs (Greatest Common Divisors) in each subsequence present in the input...

4 minutes read.

Java Integer highestOneBit()

The highestOneBit() method of Java Integer class returns an int value with at most a single one-bit, in the position of the highest-order one-bit in the specified int value.  Syntax public static...

1 minute read.

How to write basic Java Programs

Java Basic Programs In this section, we will learn how to write basic Java programs. But first we need to take care of the following requirement list. To execute a Java program,...

4 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.

nth Prime Number in Java

A number is considered prime if only divisible by one and itself. Prime numbers include, for example, 2, 3, 5, 7, 11, etc. In looking at it another way, a...

5 minutes read.

Java Queue

The Java.util package has the interface Queue, which does extend the Collection interface. It is used to protect the parts that are managed using the FIFO approach. Being an interface, the...

5 minutes read.

Features of Java

The objective of the Java programming language is to provide portability, security, and simplicity. In spite of this, Java has a number of features that makes it a popular language...

5 minutes read.

Java String subSequence() method

This method returns a new character sequence i.e. subsequence of current sequence Syntax: public CharSequence subSequence(int beginIndex, int endIndex) Parameter: beginIndex ? begin index, inclusive. endIndex ? end index, exclusive. Return: specified subsequnce Throws: It throws IndexOutOfBoundsException...

1 minute read.

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...

4 minutes read.

Java String vs StringBuffer

Java String vs StringBuffer In this section, we will discuss the key differences between String and StringBuffer class. Before moving to the ahead in this section, let’s introduce with both classes. String...

4 minutes read.

Sparse Numbers in Java

In this section, we will be very well acknowledged about the sparse numbers in Java, how a number can be verified if it is a sparse number or not. Sparse Numbers Any...

3 minutes read.

Java Binary Operators

In this article, we are going to discuss about the binary operators in Java and their operations. Also, an example program will be discussed along with the operations. These are...

6 minutes read.

Java Garbage Collection Interview Questions

One of the key areas of Java is garbage collection. Garbage collection enables apps to manage memory automatically. Interviewers frequently ask inquiries about garbage collection. Q1: What is the purpose of...

6 minutes read.

Dining Philosophers problem in Java

The Problem of the Dining Philosophers illustrates a concurrency issue involving the distribution of scarce resources among conflicting processes. Problem Statement Imagine a dining table with a circle in the middle and five...

3 minutes read.

How to Convert Timestamp to Date in Java

How to Convert Timestamp to Date in Java You can convert Timestamp to Date by using the constructor of Date class. It returns the long millisecond from Epoch (1st January 1970)...

2 minutes read.

Java Rename File

Renaming a file is the process of changing its name. Using the renameTo() function of the Java File class, renaming operations are possible. A file can be renamed using Java's renameTo()...

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.

InputMismatchException in Java

What is InputMismatchException? One of the most frequent errors in Java is the InputMismatchException. Because the InputMismatchException is a subtype of the java.lang, it is an unchecked exception. RuntimeException.Because it is...

4 minutes read.

Star Pattern Programs in Java

Star Pattern Programs in Java The star pattern programs in Java is the part of pattern programs in Java, which we discussed earlier. Right Triangle Star Pattern Filename: StarPatternExample.java public class StarPatternExample {              public static void...

4 minutes read.