J2EEOnline J2EEOnline


JDBC  «Prev  Next»
Lesson 5 Driver types
ObjectiveDefine the purpose of the four basic JDBC drivers.

JDBC Driver Types

Because each database system is different, a unique driver must be written for each. There is no universal driver that will translate between a JDBC application and any database system, unfortunately.
Typically, the drivers are furnished by the vendor of the database. In our case, Cloudscape has written a driver for us to use.
If you needed to connect to another DBMS, you would have to locate a source for an appropriate driver. For example, if you wanted to use an Oracle DBMS, you would have to obtain an appropriate driver from Oracle.
The drivers are categorized by type, and each type is distinguished by:
  1. Driver components
  2. Language used to develop the components
  3. Locations where components reside

Driver types are referred to by type, such as "Type 1 driver."
There are four types of JDBC drivers that perform mapping to the vendor protocol for database access, as described in the table below. All Type 1, 2, and 4 drivers talk directly to a database system. Type 3 drivers depend on an intermediate level to collect and direct their JDBC commands to a database.

DriverDescription
Type 1A JDBC driver that talks an ODBC driver. It provides a mechanism to use many of the existing Microsoft ODBC drivers. It requires that the ODBC driver be installed on the client machine. It is supplied by Sun as part of the core JDBC software. It is also known as the JDBC-ODBCbridge.
Type 2A driver that requires some client-side binary code, but is partially comprised of Java code; JDBC calls are converted into the database vendor's protocol and mapped to the database-specific code of the target database, usually in another language.
Type 3A driver written completely in Java. It is designed to use an indirect connection. It translates commands to a DBMS-independent format and passes them on to another process, usually a server of some sort. That server re-translates those commands with a database-specific driver to a directly connected database. Responses are directed over the same, but reversed, route.
Type 4A driver also written in Java and for a specific DBMS. It is directly connected to a database and translates commands as required by that DBMS. It doesn't need client-side code to be invoked and loaded.

In the next lesson, you will review how to create a connection to a DBMS with a driver.