JDBC
- JDBC stands for Java Database Connectivity. It is a step by step procedure to communicate with the database from the Java application in order to perform database operation. Basically, JDBC is an Application Programming Interface (API) that makes it possible to standardize and simplify the process of connecting Java applications to a database.
- DBC is considered to be a part of Java platform, Standard Edition (Java SE) uses the Structured Query Languages (SQL) for performing different database queries like access, storage, update or delete.
- Relational Database Management System (RDBMS) supports Structured Query Language (SQL). Since Java is a platform independent programming language which runs on most platforms, JDBC helps to write a single database application which can run on different platforms and interact with different Database Management Systems.
Architecture
of JDBC
·
JDBC Driver
JDBC Driver is a
software component that enables java application to interact with the database.
There are 4 types of JDBC drivers:
1.
JDBC-ODBC
bridge driver
2.
Native-API
driver (partially java driver)
3.
Network
Protocol driver (fully java driver)
4.
Thin
driver (fully java driver)
- JDBC-ODBC Bridge Driver/Type-1 Driver: There are some databases which provide ODBC driver to connect their databases. Here, ODBC stands for Open Database Connectivity. The JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function calls. This is now discouraged because of thin driver.
Figure- JDBC-ODBC Bridge Driver
A
Java application which needs to communicate with a database containing ODBC
driver will use JDBC API to communicate with JDBC-ODBC Bridge
driver. Here, this JDBC-ODBC bridge driver will communicate with the
ODBC driver and then further establish a connection with its specific database.
Advantage:
· It helps to easily connect with
the database.
Disadvantage:
· Performance degraded because
JDBC method call is converted into the ODBC function calls.
· The ODBC driver needs to be installed
on the client machine.
- Native-API driver/Type-2 Driver: Some database vendors provide only Native APIs, written in C/C++ programming languages, in order to access their database.
A Java application which wants to communicate with such databases which provide only Native APIs uses Native API driver to establish a communication. Java application is programmed using JDBC API, makes JDBC calls. Then, these JDBC calls are converted into database specific native calls using Native-API driver. Further, these native calls are passed over to database specific native library which communicates with the database
Figure- Native-API driver
Advantage: 1)
Performance is upgraded compared to JDBC-OBDC/Type 1 driver.
Disadvantage: 2) Need to install
Native API driver on each of the client machine.
· Network Protocol driver
Advantage:
- No client side library is
required because of application server that can perform many tasks like
auditing, load balancing, logging etc.
Disadvantages:
- Network support is required on
client machine.
- Requires database-specific coding to
be done in the middle tier.
- Maintenance of Network Protocol
driver becomes costly because it requires database-specific coding to be
done in the middle tier.
· Thin Driver :-
Advantage:
Disadvantage:
It is important to understand why we need Java Database Connectivity . Java application are required |
Comments
Post a Comment