0% found this document useful (0 votes)
9 views13 pages

Understanding JDBC: Drivers & Architecture

JAVA DATABASECONNECTIVITY

Uploaded by

nishacstacw
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views13 pages

Understanding JDBC: Drivers & Architecture

JAVA DATABASECONNECTIVITY

Uploaded by

nishacstacw
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Java Database Connectivity

Enterprise Application Development

Presented By
Dr. Monika Patel
Asst. Professor Computer Dept
Durga College Raipur(CG)

1
Topics
– JDBC
– API
– Architecture
– Types of Drivers
– Conceptual Components
– ODBC
– JDBC Data Types

2
JDBC
Definition
• JDBC: Java Database Connectivity
– It provides a standard library for Java programs to
connect to a database and send it commands using
SQL
– It generalizes common database access functions
into a set of common classes and methods
– Abstracts vendor specific details into a code library
making the connectivity to multiple databases
transparent to user
• JDBC API Standardizes:
– Way to establish connection to database
– Approach to initiating queries
– Method to create stored procedures
– Data structure of the query result 3
JDBC
API
• Two main packages [Link] and [Link]
– [Link] contains all core classes required for accessing
database
(Part of Java 2 SDK, Standard Edition)
– [Link] contains optional features in the JDBC 2.0 API
(part of Java 2 SDK, Enterprise Edition)
• [Link] adds functionality for enterprise
applications
– DataSources
– JNDI
– Connection Pooling
– Rowsets
– Distributed Transactions

4
JDBC
Architecture
• JDBC Consists of two
parts:
– JDBC API, a purely Java-
based API
– JDBC Driver Manager,
which communicates
with vendor-specific
drivers that perform the
real communication with
the database
• Translation to the vendor
format occurs on the client
– No changes needed to
the server
– Driver (translator)
needed on client 5
JDBC
Drivers
• JDBC uses drivers to translate
generalized JDBC calls into vendor-
specific database calls
– Drivers exist for most popular
databases
– Four Classes of JDBC drivers exist
Type I
Type II
Type III
Type IV

6
JDBC
Drivers (Type I)
• Type I driver provides mapping between JDBC and access
API of a database
– The access API calls the native API of the database to
establish communication
• A common Type I driver defines a JDBC to ODBC bridge
– ODBC is the database connectivity for databases
– JDBC driver translates JDBC calls to corresponding ODBC
calls
– Thus if ODBC driver exists for a database this bridge can be
used to communicate with the database from a Java
application
• Inefficient and narrow solution
– Inefficient, because it goes through multiple layers
Driver (Type

ODBC API
Native API
– Narrow, since functionality of JDBC code limited to whatever
Client
I)

ODBC supports Database


Application API Database
Protocol Specific
Protocol

7
JDBC
Drivers (Type II)
• Type II driver communicates directly with
native API
– Type II makes calls directly to the native API
calls
– More efficient since there is one less layer to
contend with (i.e. no ODBC)
– It is dependent on the existence of a native
API for a database
Driver (Type II)

Native API
Client
Application Database
API Database
Protocol Specific
Protocol

8
JDBC
Drivers (Type III)
• Type III driver make calls to a middleware
component running on another server
– This communication uses a database independent net
protocol
– Middleware server then makes calls to the database
using database-specific protocol
– The program sends JDBC call through the JDBC driver
to the middle tier
– Middle-tier may use Type I or II JDBC driver to
communicate with the database.
Driver (Type
III)

Client Middleware
Application Net Server Database Database
Protocol Specific
Protocol

9
JDBC
Drivers (Type IV)
• Type IV driver is an all-Java driver that is also
called a thin driver
– It issues requests directly to the database using its
native protocol
– It can be used directly on platform with a JVM
– Most efficient since requests only go through one
layer
– Simplest to deploy since no additional libraries or
middle-ware
Driver (Type
IV)

Client
Application Database Specific Database
Protocol

10
JDBC
Conceptual Components
• Driver Manager: Loads database drivers and manages
connections between the application and the driver
• Driver: Translates API calls into operations for specific
database
• Connection: Session between application and data
source
• Statement: SQL statement to perform query or update
• Metadata: Information about returned data, database,
& driver
• Result Set: Logical set of columns and rows of data
Creates Creates Creates
returned by executing
DriverManager Connectiona statementStatement Result Set

Driver
Established
Link to DB

Database
11
JDBC
Open Database Connectivity (ODBC)
• A standard database access method
developed by the SQL Access group
in 1992. ODBC Interface
– The goal of ODBC is to make it
possible to access any data from
any application, regardless of
which database management
system (DBMS) is handling the
data.
– ODBC manages this by inserting a
middle layer, called a database
driver , between an application and
the DBMS.
– The purpose of this layer is to
translate the application's data
queries into commands that the
DBMS understands.
– For this to work, both the
application and the DBMS must be
ODBC-compliant, that is, the
12
application must be capable of
issuing ODBC commands and the
JDBC – Data Types

13

You might also like