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
- JDBC API
- JDBC Driver Manager
- JDBC-ODBC Bridge
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.