Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Experiment No 11

Title : JDBC-ODBC connectivity


Aim : To study JDBC-ODBC connectivity for accessing database.
Objective: - To connect different client to database
Theory:
JDBC (Java Database Connectivity):

Definition: JDBC is a Java-based API (Application Programming Interface) that allows Java
applications to interact with relational databases. It provides a standard interface for connecting
Java applications with various database management systems (DBMS) and executing SQL
queries.
Purpose: JDBC facilitates database connectivity, enabling Java applications to perform tasks
such as executing SQL queries, retrieving and updating data, and managing transactions.
ODBC (Open Database Connectivity):

Definition: ODBC is a standard interface for connecting applications, regardless of the


programming language, to relational database management systems. It acts as a middleware
layer that allows applications to communicate with different database systems using a common
set of functions.
Purpose: ODBC provides a uniform way for applications to access and manipulate data across
various database platforms, promoting portability and reducing the effort required to adapt
applications to different databases.
JDBC:
Java JDBC
JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the
query with the database. It is a part of JavaSE (Java Standard Edition). JDBC API uses JDBC
drivers to connect with the database. There are four types of JDBC drivers:
o JDBC-ODBC Bridge Driver,
o Native Driver,
o Network Protocol Driver, and
o Thin Driver
We have discussed the above four drivers in the next chapter.
We can use JDBC API to access tabular data stored in any relational database. By the help of
JDBC API, we can save, update, delete and fetch data from the database. It is like Open
Database Connectivity (ODBC) provided by Microsoft.

The current version of JDBC is 4.3. It is the stable release since 21st September, 2017. It is
based on the X/Open SQL Call Level Interface. The java.sql package contains classes and
interfaces for JDBC API. A list of popular interfaces of JDBC API are given below:
o Driver interface
o Connection interface
o Statement interface
o PreparedStatement interface
o CallableStatement interface
o ResultSet interface
o ResultSetMetaData interface
o DatabaseMetaData interface
o RowSet interface
A list of popular classes of JDBC API are given below:
o DriverManager class
o Blob class
o Clob class
o Types class
ODBC:
How ODBC works

ODBC consists of four components, working together to enable functions. ODBC allows
programs to use SQL requests that access databases without knowing the proprietary
interfaces to the databases. ODBC handles the SQL request and converts it into a request
each database system understands.
The four different components of ODBC are:

• Application: Processes and calls the ODBC functions and submits the SQL
statements;

• Driver manager: Loads drivers for each application;

• Driver: Handles ODBC function calls, and then submits each SQL request to a
data source; and

• Data source: The data being accessed and its database management system
(DBMS) OS.

OBDC can also work with MySQL when its driver is called MyODBC. Sometimes, this is
referred to as the MySQL Connecter/ODBC.

JDBC vs. ODBC

The Java Database Connectivity (JDBC) API uses the Java programming language to access
a database. When writing programs in the Java language using JDBC APIs, users can employ
software that includes a JDBC-ODBC Bridge to access ODBC-supported databases.

However, the JDBC-ODBC Bridge (or JDBC type 1 driver) should be viewed as a
transitional approach, as it creates performance overhead because API calls must pass
through the JDBC bridge to the ODBC driver, then to the native database connectivity
interface. In addition, it was removed in Java Development Kit (JDK) 8, and Oracle does not
support the JDBC-ODBC Bridge. The use of JDBC drivers provided by database vendors,
rather than the JDBC-ODBC Bridge, is the recommended approach.

Experimental Task:-
Implement Program for JDBC-ODBC connectivity for accessing database:
Conclusion:-
From above experiment, I understood to connect the database to a java program. I
retrieved the database items using java programs.

You might also like