TYPES OF JDBC DRIVERS
We have learnt about JDBC API. Now we will study different types of drivers
available in java of which some are pure and some are impure.
available in java of which some are pure and some are impure.
To connect with individual databases, JDBC requires drivers for each database. There
are four types of drivers available in Java for database connectivity. Types 3 and 4 are
pure drivers whereas Types 1 and 2 are impure drivers. Types 1 and 2 are intended for
programmers writing applications, while Types 3 and 4 are typically used by vendorsof middleware or databases.
are four types of drivers available in Java for database connectivity. Types 3 and 4 are
pure drivers whereas Types 1 and 2 are impure drivers. Types 1 and 2 are intended for
programmers writing applications, while Types 3 and 4 are typically used by vendorsof middleware or databases.
Type 1: JDBC-ODBC Bridge
They are JDBC-ODBC Bridge drivers. They delegate the work of data access to
ODBC API. ODBC is widely used by developers to connect to databases in a non-
Java environment. This kind of driver is generally most appropriate when automatic
installation and downloading of a Java technology application is not important.
ODBC API. ODBC is widely used by developers to connect to databases in a non-
Java environment. This kind of driver is generally most appropriate when automatic
installation and downloading of a Java technology application is not important.
Note: Some ODBC native code and in many cases native database client code must be
loaded on each client machine that uses this type of driver.
loaded on each client machine that uses this type of driver.
Advantages: It acts as a good approach for learning JDBC. It may be useful for
companies that already have ODBC drivers installed on each client machine —
typically the case for Windows-based machines running productivity applications. It
may be the only way to gain access to some low-end desktop databases.
companies that already have ODBC drivers installed on each client machine —
typically the case for Windows-based machines running productivity applications. It
may be the only way to gain access to some low-end desktop databases.
Disadvantage: It is not suitable for large-scale applications. They are the slowest of
all. The performance of system may suffer because there is some overhead associated
with the translation work to go from JDBC to ODBC. It doesn’t support all the
features of Java. User is limited by the functionality of the underlying ODBC driver,
as it is product of different vendor.
all. The performance of system may suffer because there is some overhead associated
with the translation work to go from JDBC to ODBC. It doesn’t support all the
features of Java. User is limited by the functionality of the underlying ODBC driver,
as it is product of different vendor.
Type 2: Native-API partly Java technology-enabled driver
They mainly use native API for data access and provide Java wrapper classes to be
able to be invoked using JDBC drivers. It converts the calls that a developer writes to
the JDBC application programming interface into calls that connect to the client
machine’s application programming interface for a specific database, such as IBM,
Informix, Oracle or Sybase, like, the bridge driver, this style of driver requires that
some binary code be loaded on each client machine.
able to be invoked using JDBC drivers. It converts the calls that a developer writes to
the JDBC application programming interface into calls that connect to the client
machine’s application programming interface for a specific database, such as IBM,
Informix, Oracle or Sybase, like, the bridge driver, this style of driver requires that
some binary code be loaded on each client machine.
Advantage: It has a better performance than that of Type 1, in part because the Type
2 driver contains compiled code that's optimised for the back-end database server’s
operating system.
37
Disadvantage: For this, User needs to make sure the JDBC driver of the database
vendor is loaded onto each client machine. Must have compiled code for every
operating system that the application will run on. Best use is for controlled
environments, such as an intranet.
2 driver contains compiled code that's optimised for the back-end database server’s
operating system.
37
Disadvantage: For this, User needs to make sure the JDBC driver of the database
vendor is loaded onto each client machine. Must have compiled code for every
operating system that the application will run on. Best use is for controlled
environments, such as an intranet.
Type 3: A net-protocol fully Java technology-enabled driver
They are written in 100% Java and use vendor independent Net-protocol to access a
vendor independent remote listener. This listener in turn maps the vendor independent
calls to vender dependent ones. This extra step adds complexity and decreases the data
access efficiency. It is pure Java driver for database middleware, which translates
JDBC API calls into a DBMS-independent net protocol, which is then translated, to a
DBMS protocol by a server. It translates JDBC calls into the middleware vendor's
protocol, which is then converted to a database-specific protocol by the middleware
server software. This net server middleware is able to connect all of its Java
technology-based clients to many different databases. In general, this is the most
flexible JDBC API alternative.
vendor independent remote listener. This listener in turn maps the vendor independent
calls to vender dependent ones. This extra step adds complexity and decreases the data
access efficiency. It is pure Java driver for database middleware, which translates
JDBC API calls into a DBMS-independent net protocol, which is then translated, to a
DBMS protocol by a server. It translates JDBC calls into the middleware vendor's
protocol, which is then converted to a database-specific protocol by the middleware
server software. This net server middleware is able to connect all of its Java
technology-based clients to many different databases. In general, this is the most
flexible JDBC API alternative.
Advantage: It has better performance than Types 1 and 2. It can be used when a
company has multiple databases and wants to use a single JDBC driver to connect to
all of them. Since, it is server-based, so there is no requirement for JDBC driver code
on client machine. For performance reasons, the back-end server component is
optimized for the operating system that the database is running on.
company has multiple databases and wants to use a single JDBC driver to connect to
all of them. Since, it is server-based, so there is no requirement for JDBC driver code
on client machine. For performance reasons, the back-end server component is
optimized for the operating system that the database is running on.
Disadvantage: It needs some database-specific code on the middleware server. If the
middleware is to run on different platforms, then Type 4 driver might be more
effective.
middleware is to run on different platforms, then Type 4 driver might be more
effective.
Type 4: A native-protocol fully Java technology-enabled driver
It is direct-to-database pure Java driver. It converts JDBC technology calls into the
network protocol used by different DBMSs directly. Basically it converts JDBC calls
into packets that are sent over the network in the proprietary format used by the
specific database. Allows a direct call from the client machine to the database.
network protocol used by different DBMSs directly. Basically it converts JDBC calls
into packets that are sent over the network in the proprietary format used by the
specific database. Allows a direct call from the client machine to the database.
Advantage: It again has better performance than Types 1 and 2 and there is no need
to install special software on client or server. It can be downloaded dynamically.
to install special software on client or server. It can be downloaded dynamically.
Disadvantage: It is not optimized for server operating system, so the driver can’t take
advantage of operating system features. (The driver is optimized for the specific
database and can take advantage of the database vendor's functionality.). For this, user
needs a different driver for each different database.
advantage of operating system features. (The driver is optimized for the specific
database and can take advantage of the database vendor's functionality.). For this, user
needs a different driver for each different database.
The following figure shows a side-by-side comparison of the implementation of each
JDBC driver type. All four implementations show a Java application or applet using
the JDBC API to communicate through the JDBC Driver Manager with a specific
JDBC driver
JDBC driver type. All four implementations show a Java application or applet using
the JDBC API to communicate through the JDBC Driver Manager with a specific
JDBC driver
No comments:
Post a Comment