5/12/26, 1:03 PM JDBC (Java Database Connectivity) - GeeksforGeeks
Courses
Search... Tutorials Sign In
Interview Prep
Java Tutorial Advanced Java Interview Questions Exercises Examples Quizzes Projects Cheatsheet DSA in Java Java Collection
JDBC (Java Database Connectivity)
Last Updated : 2 Jan, 2026
JDBC is an API that helps applications to communicate with databases. It allows Java programs to
connect to a database, run queries, retrieve and manipulate data. Because of JDBC, Java applications
can easily work with different relational databases like MySQL, Oracle, PostgreSQL and more.
JDBC Architecture
JDBC Architecture
Components of JDBC
1. Application: It can be a Java application or servlet that communicates with a data source.
2. JDBC API: It allows Java programs to execute SQL queries and get results from the database.
Some key components of JDBC API include
Interfaces like Driver, ResultSet, RowSet, PreparedStatement and Connection that helps
managing different database tasks.
Classes like DriverManager, Types, Blob and Clob that helps managing database connections.
3. DriverManager: It plays an important role in the JDBC architecture. It uses some database-specific
drivers to effectively connect enterprise applications to databases.
4. JDBC drivers: These drivers handle interactions between the application and the database.
JDBC Processing Models
[Link] w w .[Link]/java/introduction-to-jdbc/ 1/4
5/12/26, 1:03 PM JDBC (Java Database Connectivity) - GeeksforGeeks
The JDBC architecture consists of two-tier and three-tier processing models to access a database.
They are as described below:
1. Two-Tier Architecture
A Java Application communicates directly with the database using a JDBC driver. It sends queries to
the database and then the result is sent back to the application. For example, in a client/server
setup, the user's system acts as a client that communicates with a remote database server.
Structure:
Client Application (Java) -> JDBC Driver -> Database
2. Three-Tier Architecture
In this, user queries are sent to a middle-tier services, which interacts with the database. The
database results are processed by the middle tier and then sent back to the user.
Structure:
Client Application -> Application Server -> JDBC Driver -> Database
JDBC Drivers
JDBC drivers are client-side adapters (installed on the client machine, not on the server) that
convert requests from Java programs to a protocol that the DBMS can understand. There are 4
types of JDBC drivers:
1. Type-1 driver or JDBC-ODBC bridge driver
2. Type-2 driver or Native-API driver (partially java driver)
3. Type-3 driver or Network Protocol driver (fully java driver)
4. Type-4 driver or Thin driver (fully java driver) - It is a widely used driver. The older drivers like
(JDBC-ODBC) bridge driver have been deprecated and no longer supported in modern versions of
Java.
JDBC Classes and Interfaces
Class/Interfaces Description
DriverManager Manages JDBC drivers and establishes database connections.
Connection Represents a session with a specific database.
Statement Used to execute static SQL queries.
PreparedStatement Precompiled SQL statement, used for dynamic queries with parameters.
CallableStatement Used to execute stored procedures in the database.
[Link] w w .[Link]/java/introduction-to-jdbc/ 2/4
5/12/26, 1:03 PM JDBC (Java Database Connectivity) - GeeksforGeeks
Class/Interfaces Description
Represents the result set of a query, allowing navigation through the
ResultSet
rows.
SQLException Handles SQL-related exceptions during database operations.
Related Article
MySQL JDBC Connection
Introduction to Database Connectivity and JDBC Visit Course
Suggested Quiz 3 Questions
What is the primary purpose of JDBC?
A To design webpages
B To connect Java applications with databases
C To compile SQL queries
D To encrypt data
Login to View Explanation 1/3 < Previous Next >
[Link] w w .[Link]/java/introduction-to-jdbc/ 3/4
5/12/26, 1:03 PM JDBC (Java Database Connectivity) - GeeksforGeeks
Comment V vinaya… 164
Article Tags: Java JDBC java-advanced
Explore
Basics
OOP & Interfaces
Collections
Exception Handling
Java Advanced
Practice Java
Java Courses
Company Explore Tutorials Courses Videos Preparation
About Us POTD Programming ML and Data DSA Corner
Corporate & Communications Address: Legal Job-A- Languages Science Python Interview
Privacy Thon DSA DSA and Java Corner
A-143, 7th Floor, Sovereign Corporate
Tower, Sector- 136, Noida, Uttar Policy Blogs Web Placements C++ Aptitude
Pradesh (201305) Contact Us Nation Technology Web Web Puzzles
Advertise Skill Up AI, ML & Data Development Development GfG 160
Registered Address:
with us Science Programming Data Science System
K 061, Tower K, Gulshan Vivante GFG DevOps Languages CS Subjects Design
Apartment, Sector 137, Noida,
Corporate CS Core DevOps &
Gautam Buddh Nagar, Uttar Pradesh,
201305 Solution Subjects Cloud
Campus Interview GATE
Training Preparation Trending
Program Software and Technologies
Tools
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
[Link] w w .[Link]/java/introduction-to-jdbc/ 4/4