JDBC Drivers - The Differences

Oracle offers a number of different JDBC drivers to interface with the database, but deciding which driver to use and when is not so straight forward! What the facts are and how to make the correct decision are explained very clearly in this OTN document. The extended entry below, also has the selected details.

What types of JDBC drivers does Oracle provide?

Oracle provides four different types of JDBC drivers, for use in different deployment scenarios. This drivers can access Oracle 7.3.4 and higher. While all Oracle JDBC drivers are similar, some features apply only to JDBC OCI drivers and some apply only to the JDBC Thin driver.

JDBC OCI client-side driver:
This is a JDBC Type 2 driver that uses Java native methods to call entrypoints in an underlying C library. That C library, called OCI (Oracle Call Interface), interacts with an Oracle database. The JDBC OCI driver requires an Oracle7.3.4 (or better) client installation (including SQL*Net v2.3 or better) and all other dependent files.

The use of native methods makes the JDBC OCI driver platform specific. Oracle supports Solaris, Windows, and many other platforms. This means that the Oracle JDBC OCI driver is not appropriate for Java applets, because it depends on a C library to be preinstalled.

JDBC Thin client-side driver:
This is a JDBC Type 4 driver that uses Java to connect directly to Oracle. It emulates Oracle's SQL*Net Net8 and TTC adapters using its own TCP/IP based Java socket implementation. The JDBC Thin driver does not require Oracle client software to be installed, but does require the server to be configured with a TCP/IP listener.

Because it is written entirely in Java, this driver is platform-independent. The JDBC Thin driver can be downloaded into any browser as part of a Java application. (Note that if running in a client browser, that browser must allow the applet to open a Java socket connection back to the server.)

JDBC Thin server-side driver:
This is another JDBC Type 4 driver that uses Java to connect directly to Oracle. This driver is used internally by the JServer within the Oracle server. This driver offers the same functionality as the client-side JDBC Thin driver (above), but runs inside an Oracle database and is used to access remote databases.

Because it is written entirely in Java, this driver is platform-independent. There is no difference in your code between using the Thin driver from a client application or from inside a server.

JDBC KPRB server-side driver:
This is another JDBC Type 2 driver that uses Java native methods to call entrypoints in an underlying C library. That C library, called KPRB, is part of the Oracle server process and communicates directly with the internal SQL engine inside Oracle. The driver accesses the SQL engine by using internal function calls and thus avoiding any network traffic. This allows your Java code running in the server to access the underlying database in the fastest possible manner. It can only be used to access the same database.

The use of native methods makes the JDBC KPRB driver platform specific. This server-side internal driver is fully consistent with the client-side drivers and supports the same features and extensions.

One customer asked Oracle for an JDBC Type1 driver. This is really an Oracle ODBC (not JDBC) driver, that you connect to using a JDBC-ODBC bridge driver. Oracle does supply an ODBC driver, but does not supply a bridge driver. Instead, you can get one of these JDBC-ODBC bridge drivers from http://java.sun.com/products/jdbc/drivers.html. This configuration should work, but a JDBC type2 or type4 driver will have more features, and will be faster.