Before
starting to learn JAVA DATABASE CONNECTIVITY, We must ask "What is an API?"
What is an API?
API
stands for application programming interface. Think of API as the interface between the device and the service requested.
In
order to understand what an API is let us consider a real time example:
Suppose
you are in a restraint and you have the menu with you .Now you have selected
your item and you want to order it. How will you do this? There is an option of
going directly into the kitchen and asking them to prepare your meal.
I
am sure that no one would go for this method. The second option available for
us is to call the waiter in the restaurant and order your item. The waiter then
contacts the kitchen and asks them to prepare your order. So, you need someone
who can collect your request and make the job done. You need a mediator to
communicate.
Similar
to the waiter in the restaurant ,an API acts as an interface between your
device and the requested service.
What
does API contain?
API
consists of all the classes and methods which are required to communicate to
the service and accomplish its task.
Formally
speaking, In computer programming an API is a set of subroutine definitions,
protocols and tools for building software and applications. API make the life of a developer easy. Since it contains
all the interfaces and classes , it makes easier for a developer to build
applications in no time.
We
already know that graphical user interface is required to interact with an
application. Similarly an API acts as an interface between the developer and a
specific technology which the developer/programmer wants to use in his
application or software.
Introduction
to JDBC :
JDBC
stands for java database connectivity. JDBC is an API which helps in connecting
and executing queries in the database.
JDBC
API uses JDBC drivers to connect with the database.
JDBC
API is written in java programming language.
Before
JDBC:
Before
JDBC API was invented, we were using ODBC (open database connectivity) which
was written entirely in C language which was platform dependent and unsecured.
So java created JDBC API in order to connect with the database.
So
far we have learnt what an API is and what is JDBC. Now let us learn what is JDBC
driver.
We
all know that JDBC API uses JDBC driver to connect with the database. JDBC
driver is a software component which enables java to interact with the database.
There
are 4 types of JDBC drivers :
- . JDBC-ODBC driver
- Native API driver
- . h Network protocol driver
- Thin driver
-
1. JDBC-ODBC driver:
JDBC-ODBC
driver uses ODBC driver to connect to the database. The JDBC-ODBC bridge driver
converts JDBC method calls into ODBC function calls. This is not encouraged at
present because of the invention of the “thin driver”.
Advantages:
1. It
is easy to use.
2. There
is not a lot of connection specific code. It can be connected to any database.
Disadvantages
of JDBC-ODBC driver:
1. Since
there is a conversion involved in JDBC to ODBC calls, the performance is
degraded.
2. The
major disadvantage of using JDBC-ODBC driver is that it was compulsory that the
ODBC driver must be installed in the user devices inorder to interact with the
database.
2. NATIVE API DRIVER:
This
is partially written in java. It uses the client side libraries of the database.
The driver converts the JDBC calls into the native calls of the database API.
Advantages:
1. Upgradation
from the JDBC bridge driver into database specific API.
Disadvantage
:
1. The
driver must be installed on every device.
2. The
database specific library must be present on the client system.
3. Network Protocol driver:
This
driver uses an intermediate application server which coverts the JDBC calls into driver specific calls.
This
is mostly written in java.
Advantage:
1. The
major advantage of the Network protocol driver is that it does not require that
the library must be installed on the client device.
Disadvantages:
1. Network
support is required.
2. Overhead
of maintaining the server.
3. Implementation
is costly.
4. Thin Driver:
The
thin driver directly coverts JDBC calls into database specific calls. Hence it
is known as the thin driver.
Thin
driver is fully written in java.
Advantages:
1. Better
performance when compared to all the other drivers.
2. No
need of any server.
Disadvantage:
1. The driver depends upon the specific datbase.
Comments
Post a Comment
Thanks for your comments!