Java Database
Connectivity
B. Sadhana
2024MCA39
Introduction to Java
Database Connectivity
(JDBC)
•JDBC (Java Database Connectivity) is an API that enables Java
applications to interact with relational databases.
•It allows Java programs to execute SQL queries, retrieve
results, and perform database operations efficiently.
•JDBC provides a standardized way to connect to different
databases like MySQL, PostgreSQL, Oracle, and more.
Why Use JDBC?
1 Enables Database 2 Platform
Operations Independence
JDBC empowers Java JDBC (Java Database
applications to perform Connectivity) allows
crucial database Java programs to
functions. These connect to
include querying, databases, no
updating, and matter which
managing data. operating system
(Windows, Linux,
3 Multi-Database Support
macOS, etc.) is being
Connect to a wide array of databases. Options include
used.
MySQL, PostgreSQL, Oracle, and many others.
JDBC Architecture
JDBC API
Defines standard interfaces and classes. It provides the
blueprint for interaction.
Driver Manager
Manages drivers and connections. It acts as a central hub.
JDBC Drivers
Facilitates communication with databases. Different
types cater to specific needs.
Database
Stores and retrieves data. It is the core repository.
Types of JDBC Drivers
JDBC-ODBC Bridge Native API Driver Network Protocol Thin (Pure Java)
Uses ODBC to connect Uses vendor-specific Connect to the Connects directly to
the database. libraries to connect . It database over the the database. This is
works on specific network using middle the most common
platform- it is not server. type.
portable.
Key JDBC Components
DriverManager Connection
Manages database Represents an active
drivers. It establishes connection. This connects
connections between to the database.
applications and
databases.
Statement
Executes static SQL queries. It is for simple queries.
More JDBC Components
PreparedStatement ResultSet
Precompiled SQL statements. Holds data from a database
Allows dynamic queries with query. Enables navigation
parameters. through the results.