JDBC Drivers:What are they?

JDBC has been a widely used API since long for interaction between Java Programs and various Databases.

From a Java programmer’s perspective,JDBC API serves the following mentioned functions:

  • Loading the appropriate JDBC Driver
  • Creating connection with a database or a table based datasource.
  • Sends SQL Statements to the database/source.
  • Processing of the retrieved results.

Loading the driver is accomplished either by setting the jdbc.drivers system property, or by dynamically loading the appropriate driver class with a call to Class.forName().

try {
 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 Class.forName("com.oracle.jdbc.OracleDriver");
}
catch (ClassNotFoundException e) {
 /* Handle Exception */
}

Type of JDBC Drivers

There are essentially four different types of JDBC Drivers which are categorized as

1.) Type 1/JDBC-ODBC Bridge plus ODBC Driver: This combination provides JDBC access via ODBC drivers. ODBC binary code — and in many cases, database client code — must be loaded on each client machine that uses a JDBC-ODBC Bridge.

Type1 Driver

Sun provides a JDBC-ODBC Bridge driver, which is appropriate for experimental use and for situations in which no other driver is available.

Type 1 drivers use a bridge technology to connect a Java client to an ODBC database system. The JDBC-ODBC Bridge from Sun and InterSolv is the only existing example of a Type 1 driver. Type 1 drivers require some sort of non-Java software to be installed on the machine running your code, and they are implemented using native code.

2.)Type 2/A native API partly Java technology-enabled driver: This type of driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix, DB2, or other DBMS.

Type 2 Driver

Note that, like the bridge driver, this style of driver requires that some binary code be loaded on each client machine.

Type 2 drivers use a native code library to access a database, wrapping a thin layer of Java around the native library. For example, with Oracle databases, the native access might be through the Oracle Call Interface (OCI) libraries that were originally designed for C/C++ programmers. Type 2 drivers are implemented with native code, so they may perform better than all-Java drivers, but they also add an element of risk, as a defect in the native code can crash the Java Virtual Machine.

3.)Type 3/Pure Java Driver for Database Middleware: This style of driver translates JDBC calls into the middleware vendor’s protocol, which is then translated to a DBMS protocol by a middleware server.

Type 3 Driver

The middleware provides connectivity to many different databases.

Type 3 drivers define a generic network protocol that interfaces with a piece of custom middleware. The middleware component might use any other type of driver to provide the actual database access. BEA’s WebLogic product line (formerly known as WebLogic Tengah and before that as jdbcKona/T3) is an example. These drivers are especially useful for applet deployment, since the actual JDBC classes can be written entirely in Java and downloaded by the client on the fly.

4.)Type 4/Pure Java Driver: This style of driver converts JDBC calls into the network protocol used directly by DBMSs, allowing a direct call from the client machine to the DBMS server and providing a practical solution for intranet access.

Type 4 Driver

Type 4 drivers are written entirely in Java. They understand database-specific networking protocols and can access the database directly without any additional software. These drivers are also well suited for applet programming, provided that the Java security manager allows TCP/IP connections to the database server.

Java Related Reads:

Java: Lifecycle of a Java Program

Why Java?

How to get free available memory in Java program

How do I declare a constant in Java

Wat is the difference between JDK and JRE?

Write a Java Application without a main() method

[Content References: Sun , OnJava]

[Image Source: Answers.com]

In my coming posts, i will try to share more about Java and JDBC with you.
Cheers,

Vaibhav

Advertisements

5 Responses

  1. Nice post. A bit of history.

    JDBC was inspired by ODBC an early API from Microsoft for providing windows drivers for multiple databases. Ours was in fact the first product to support ODBC (back in 1991-92). Microsoft Access was the second.

    Till ODBC/JDBC came along, you had to write to different APIs to support different databases , a perfect nightmare.

    Today we take it for granted. The elegance of a provider/consumer model has been made popular by ODBC/JDBC combo.

  2. This is great to know Dorai. I believe sometime we should discuss more about your product and the experiences. Lots to learn in this world 🙂
    Cheers
    Vaibhav

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: