Professional Documents
Culture Documents
JDBC
Introduction : JDBC
• JDBC Driver is a software component that enables java application to interact with the
database.
• The JDBC specification related API in the form of java.sql package.
• Each JDBC driver is set of classes implementing various interfaces of JDBC API packages.
While defining methods of these interfaces the classes contain logic to interact with specific
database software. JDBC uses jar files.
• A JAR (Java ARchive) file is a file that contains the class, image, and sound files for a Java
application or applet gathered into a single file and possibly compressed.
• When a programmer gets a Java program development kit, a small program or utility called
"jar" is included.
Difference between ODBC and JDBC
• OBDC is Microsoft drivers and uses dlls, JDBC is Java drivers and uses
jar files.
• ODBC is procedural oriented and JDBC is object oriented.
• ODBC can't be directly used with Java because it uses a C interface.
• ODBC makes use of pointers which have been removed totally from Java.
• ODBC mixes simple and advanced features together and has complex
options for simple queries.
• But JDBC is designed to keep things simple while allowing advanced
capabilities when required.
….
• ODBC requires manual installation of the ODBC driver manager and driver
on all client machines.
• JDBC drivers are written in java and JDBC code is automatically installable,
secure, and portable on all platforms.
• JDBC API is a natural Java Interface and is built on ODBC. JDBC retains
some of the basic feature of ODBC.
• JDBC is Java Database Connectivity. It enables java programs to execute
SQL statements. JDBC makes it possible to write a single database
application that can run on different platforms and interact with different
DBMS.
• JDBC is language dependent i.e it is used only to make connectivity with
java. ODBC is open database connectivity. 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 so it is
language independent.
• ODBC is language independent and JDBC is language dependent.
JDBC Drivers
JDBC API
• The JDBC API is a Java API for accessing virtually any kind of tabular data. (As a
point of interest, JDBC is the trademarked name and is not an acronym; nevertheless,
JDBC is often thought of as standing for "Java Database Connectivity.")
• The JDBC API makes it easy to send SQL statements to relational database systems
and supports all dialects of SQL.
• The value of the JDBC API is that an application can access virtually any data source
and run on any platform with a Java Virtual Machine.
• JDBC API provides a standard abstraction for Java application to access JOBC
drivers, which is implemented by 3rd party vendor, i.e., database.
• JDBC API defines a standard protocol between a Java application and JDBC driver.
Goal of JAVA-API
The JDBC-ODBC bridge driver uses ODBC driver to connect to the database. The JDBC-
ODBC bridge driver converts JDBC method calls into the ODBC function calls.
This is now discouraged because of thin driver.
Advantages:
• easy to use.
• can be easily connected to any database.
Disadvantages:
• Performance degraded because JDBC method call is converted into the ODBC function
calls.
• The ODBC driver needs to be installed on the client machine.
JDBC-ODBC bridge driver
Native-API driver
The JDBC API supports both two-tier and three-tier models for
database access.
• Two-Tier Model
• In the two-tier model, a Java applet or application talks directly to
the data source.
• This requires a JDBC driver that can communicate with the
particular data source being accessed.
• A user's commands are delivered to the database or other data
source, and the results of those statements are sent back to the user.
• The data source may be located on another machine to which the
user is connected via a network.
• This is referred to as a client/server configuration, with the user's
machine as the client, and the machine housing the data source as
the server.
• The network can be an intranet, which, for example, connects
employees within a corporation, or it can be the Internet.
Three-Tier Model
• Commands are sent to a "middle tier" of services, which then sends the commands to the data
source.
• The data source processes the commands and sends the results back to the middle tier, which
then sends them to the user.
• MIS directors find the three-tier model very attractive because the middle tier makes it possible
to maintain control over access and the kinds of updates that can be made to corporate data.
• Another advantage is that it simplifies the deployment of applications. Finally, in many cases,
the three-tier architecture can provide performance advantages.
Three-Tier Model
• With enterprises increasingly using the Java programming language for writing server code
• JDBC API is being used more and more in the middle tier of a three-tier architecture. Some of
the features that make
• JDBC a server technology are its support for connection pooling, distributed transactions, and
disconnected rowsets. And, of course, the JDBC API is what allows access to a data source
from a Java middle tier.
THANK YOU