Home

JDBC

JDBC, Java Database Connectivity, is a Java API that provides a standard way for Java applications to interact with relational databases using SQL. It abstracts database-specific details behind a uniform set of interfaces, allowing code to work with multiple database systems through drivers.

The core elements of JDBC include the Driver, which implements the database-specific communication, and the DriverManager

How JDBC works in practice involves loading a JDBC driver, obtaining a Connection from DriverManager or a

There are several driver models in JDBC: Type 1 bridging drivers, Type 2 native library drivers, Type

Key features of JDBC include support for prepared statements with parameter binding, batch updates, and stored

JDBC is part of the Java Platform, Standard Edition, with the API located in java.sql and javax.sql.

or
DataSource,
which
manage
connections.
The
primary
objects
used
in
data
access
are
Connection,
Statement
(and
its
subtypes
PreparedStatement
and
CallableStatement),
and
ResultSet.
Error
handling
is
performed
through
SQLException,
and
database
or
result
set
metadata
is
accessed
via
DatabaseMetaData
and
ResultSetMetaData.
DataSource,
creating
a
Statement
or
PreparedStatement
to
execute
SQL,
processing
results
in
a
ResultSet,
and
finally
closing
resources.
Transactions
are
controlled
through
the
Connection,
with
options
for
autocommit
on
or
manual
commit
and
rollback
as
needed.
3
network-protocol
drivers,
and
Type
4
pure
Java
drivers.
Type
4
drivers,
which
communicate
directly
with
the
database
protocol
in
pure
Java,
are
the
most
common
in
modern
environments
due
to
simplicity
and
portability.
procedures
via
CallableStatement,
along
with
transaction
management
and
database
metadata
access.
Connection
pooling
is
typically
provided
by
higher-level
frameworks
through
DataSource
rather
than
directly
by
JDBC,
and
proper
error
handling
and
resource
management
are
essential
for
robust
database
applications.
Database
vendors
provide
distinct
JDBC
drivers
to
enable
connectivity,
and
compatibility
is
tied
to
the
JDBC
version
supported
by
the
Java
runtime.