Recent Pos

Understanding The JDBC Driver Types Architecture

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail

⇒ The JDBC driver is a well defined set of objects driving the JDBC API calls towards the database server.

⇒ The JDBC drivers are categorized in to 4 types. The current version of JDBC is 4.0 and the earlier version are 1.0, 2.0 and 3.0.

⇒ As per the JDBC 4.0 we have only 4 types of JDBC drivers. In recent days there is going discussion in community about type-5 but yet no standardization/conclusion on it.

classify jdbc driver types according to their architecture

⇒ The JDBC drivers are implemented by 3rd party vendors and as of now we have 300+ JDBC drivers available in the market.

JDBC Type-1 driver:

⇒ It is a JDBC driver that converts JDBC API calls into database independent API calls like ODBC.
jdbc type-1 driver

⇒ As this driver forms a bridge between JDBC and ODBC APIs, this is known as JDBC-ODBC bridge driver.

⇒ According to the Type-1 architecture, JDBC driver itself cannot connect with the database directly. (i.e. it must depend on the third party driver)

⇒ In the above architecture JDBC ODBC driver is implemented on Type-1 driver standard from Sun Microsystems.

⇒ JDBC ODBC driver understand coming Java call from Java application and it converts into ODBC call. (i.e. ODBC call is also known as native call or C call)

⇒ These converted ODBC calls are handover to the third party driver (i.e. in this case Microsoft ODBC driver)

⇒ Microsoft ODBC driver convert the given ODBC call into database calls and get connected with the target database.

Advantages:

⇒ This is a database independent driver.

⇒ This introduces the support for Java application access any database that is supported by ODBC. This is much important in the initial release of JDBC. And even if any database doesn’t directly support JDBC.

⇒ This driver is bundled and imported with default Java software product.

Disadvantages:

⇒ In some cases the number of conversions are found more compared to the other 3 Type of JDBC drivers. This increases the request processing time and effects the performance of the system.

⇒ As discussed earlier ODBC API doesn’t include few of the database specific features which effects Java application using such features with this type of JDBC driver.

⇒ This driver is tightly depends on the third party driver.

⇒ Depending on the third party driver makes Java application as OS dependent.

⇒ ODBC driver is not updated from the Microsoft so depending on the 3rd party driver makes Java application low level features of database.

Situations to use this type of driver:

⇒ WE may use this type of driver in the development and initial testing as we may not yet decided the JDBC driver go in the live.

⇒ We may use this type of driver in the production only if we don’t have the other type of JDBC driver for accessing the selected datastore like MS-Access and Excel sheet.

JDBC Type-2 driver:

⇒ It is a JDBC dirver that converts JDBC API calls to DB vendor driver API calls.

jdbc type-2 driver

⇒ The JDBC Type-2 driver is implemented partly in Java and partly in Native language.

⇒ This Type of drivers are named as part-Java and part-Native drivers.

Advantages:

⇒ The only advantage we find with the Type-2 driver is its speed of operation. It is much faster working compared to the Type-1 driver.

Disadvantages:

⇒ To work with this type of driver we find the DB vendor Native libs o install in the client machine. And these libs needs to be loaded into the Java application process.

⇒ Thus any bug in the native libs can crash our application JRE.

⇒ This makes the application heavy weight compared to Type-3 and Type-4.

Situation to use this type of driver:

⇒ This type of driver is used only in server side running applications, if the native libraries are from the trusted vendor and are perfectly tested for no bugs.

JDBC Type-3 driver:

⇒ A JDBC driver that converts JDBC API calls into DB independent network calls is known as Type-3 driver.

jdbc type-3 driver

Advantages:

⇒ This is the only driver with 3-Tier architecture.

⇒ This can hide the database details such as location and the username/password from the client which can increase the security.

⇒ This supports to manage the database resources properly to service more number of clients. This can be implemented into the middle-ware server.

⇒ This is much convenient driver to access the database server n the networks.

⇒ This is suitable to use in the distributed transaction environment.

Disadvantages:

⇒ This driver in some cases is found costlier to have the middle-ware server, like if we have single client simple application.

JDBC Type-4 driver:

⇒ The JDBC driver that converts JDBC API calls into DB N/W calls is known as JDBC Type-4 driver.

⇒ This type of driver is completely implemented in Java, thus these drivers are referred as Pure Java Driver.

jdbc type-4 driver

Advantages:

⇒ This is light weight compared to the other type of drivers.

⇒ This is platform independent.

⇒ No native libraries to install in the client that means DB client software is not required to be installed in the client machine.

Disadvantages:

⇒ Nothing major disadvantages but these driver are required to be implemented most of the time by the DB vendor as we know that the DB network protocols are not properly documented, thus the availability of this type of driver would be a point to consider.

Situation to use:

⇒ This type of driver well suitable of the client and server side applications.

⇒ This would be the choice in case of Type-3 driver is not applicable for our requirement.

JDBC driver Type comparison chart:

TypeDB IndependentConverts toAdvantageDisadvantage
Type-1YesDB Independent API callSupports all DB of ODBCMore no. of conversions
Type-2NoDB Vendor API callSpeed of operationRequire native lib
Type-3YesDB Independent N/W callBetter resource managementRequire Middle-ware server
Type-4NoDB vendor network callLight weightAvailability

<-Previous: JDBC Driver API | | Next->Working With JDBC Driver API

No Comments

Post a Comment