Friday 24 August 2012

JDBC Driver Types


What is JDBC Driver?


JDBC is a software component enabling a java application to interact with a database.For connecting with databases, JDBC requires drivers for each database. The JDBC driver established the connection to the database and implements the protocols for transferring the queries and result between client and database.
The Java.sql package that ships with JDK contains various classes with their behaviours defined and their actual implementaions are done in third-party drivers. Third party vendors implements the java.sql.Driver interface in their database driver.

Types of JDBC Drivers:

JDBC driver implementations vary because of the wide variety of operating systems and hardware platforms in which Java operates. Sun has divided the implementation types into four categories, Types 1, 2, 3, and 4.
 

4 types of jdbc drivers are elaborated in detail as shown below:

>Type 1: JDBC-ODBC Bridge driver (Bridge)
>Type 2: Native-API/partly Java driver (Native)
>Type 3: Net-protocol driver (Middleware)
>Type 4: Native-protocol driver (Pure)
 

Type 1 JDBC Driver -- JDBC-ODBC Bridge driver

The JDBC type 1 driver, also known as the JDBC-ODBC bridge, is a database driver implementation that employs the ODBC driver to connect to the database. The Type 1 driver translates all JDBC calls into ODBC calls and sends them to the ODBC driver. ODBC is a generic API.
The JDBC-ODBC Bridge driver is recommended only for experimental use or when no other alternative is available. This driver is included in the Java 2 SDK within the sun.jdbc.odbc package. In this driver the java statements are converted to a jdbc statements. JDBC statements calls the ODBC by using the JDBC-ODBC Bridge. And finally the query is executed by the database. This driver has serious limitation for many applications.

Advantages:

1). The JDBC-ODBC Bridge allows access to almost any database, since the database’s ODBC drivers are already available.
2). Easy to connect directly to the database.

Disadvantages:

1). The client system requires the ODBC Installation to use the driver.
2). The ODBC driver needs to be installed on the client machine.
3). Not good for the Web.
4). Not suitable for applets, because the ODBC driver needs to be installed on the client.
5). Since the Bridge driver is not written fully in Java, Type 1 drivers are not portable.
6). A performance issue is seen as a JDBC call goes through the bridge to the ODBC driver, then to the database, and this applies even in the reverse process. They are the slowest of all driver types.
 
 
 

No comments:

Post a Comment