Monday, August 4, 2008

==> Comparision of JDBC Drivers

Types Of Drivers :

1. Type-1 (JDBC ODBC-Bridge Driver)
2. Type-2 (Java-Native API Driver / Native API Partly JAVA Driver / Thick Driver)
3. Type-3 (Java Net Protocol Driver / Intermediate DataBase Access Server)
4. Type-4 (Java Native Protocol driver / Pure JAVA Driver / Thin driver)

Type-1 : JDBC-ODBC Bridge Driver :

Since ODBC is written in C-language using pointers, so JAVA does’t support pointers, a java program can’t communate directly with the DataBase. The JDBC-ODBC bridge drivertransulates JDBC API calls to ODBC API calls.

Advantages :

1) Simple to use because ODBC drivers comes with DB installation/Microsoft front/back office product installation
2) JDBC ODBC Drivers comes with JDK software

Disadvantages :

1) More number of layers between the application and DB. And more number of API conversions leads to the downfall of the performance.
2) Slower than type-2 driver.

Where to use :

This type of drivers are generaly used at the development time to test your application’s.
Because of the disadvantages listed above it is not used at production time. But if we are not available with any other type of driver implementations for a DB then we are forced to use this type of driver (for example Microsoft Access)

Type-2 : Native API Partly JAVA Driver / Thick Driver :

JDBC Database calls are translated into Vendor-specific API calls. The database will process the request and send the results back through API to JDBC Driver – this will translate the results to the JDBC standard and return them to the Java application. The Vendor specific language API must be installed on every client that runs the JAVA application.

Advantages :

1) Faster than the other types of drivers due to native library participation in socket programing.

Disadvantage :

1) DB spcifiic native client library has to be installed in the client machine.
2) Preferablly work in local network environment because network service name must be configured in client system

Where to use :

This type of drivers are suitable to be used in server side applications.
Not recommended to use with the applications using two tire model (i.e. client and database layer’s) because in this type of model client used to interact with DB using the driver and in such a situation the client system sould have the DB native library.

Type-3 Intermediate DataBase Access Server :

Type-3 Driver uses an Intermediate(middleware) database driver that has the ability to connect multiple JAVA clients to multiple database servers. Client connect to the Databse server via an Intermediate server component (such as listener) that acts as a gateway for multple database servers. Bea weblogic includes Type-3 Driver.

Advantages :

1) It allows the flexibility on the architecture of the application.
2) In absence of DB vendor supplied driver we can use this driver
3) Suitable for Applet clients to connect DB, because it uses Java libraries for communication between client and server.

Disadvantages :

1) From client to server communication this driver uses Java libraries, but from server to DB connectivity this driver uses native libraries, hence number of API conversion and layer of interactions increases to perform operations that leads to performance deficit.
2) Third party vendor dependent and this driver may not provide suitable driver for all DBs

Where to use :

Suitable for Applets when connecting to databases

Type-4 Pure JAVA Driver / Thin driver :

Type-4 Driver translates JDBC-API calls to direct network calls using vendor specific networking protocols by making direct server connections with the database.

Advantage :

1) Type-4 driver are simple to deploy since there is No client native libraries required to be installed in client machine
2) Comes with most of the Databases

Disadvantages :

1) Slower in execution compared with other JDBC Driver due to Java libraries are used in socket communication with the DB

Where to use :

This type of drivers are sutable to be used with server side applications, client side application and Java Applets also.

No comments: