Problem solve Get help with specific problems with your technologies, process and projects.

Choosing the appropriate JDBC Driver to connect to an Oracle database

Read this tip on how to choose among JDBC drivers for Oracle 8i.

Oracle 8i provides two different client-side programmatic interfaces for Java developers to access data stored in the database: JDBC and SQLJ. Oracle expert Megh Thakkar discusses the JDBC drivers that can be used and tells how to choose among them in this article from InformIT:

Java Database Connectivity (JDBC) is a standard API that enables application developers to access and manipulate relational databases from within Java programs. The JDBC standard was defined by Sun Microsystems. It enables individual providers to implement and extend the standard with their own JDBC drivers. JDBC is based on the X/Open SQL Call Level Interface (CLI) and complies with the SQL-92 Entry Level standard, which provides a DBMS-independent interface that enables access to the database from Java.

The JDBC framework includes a JDBC driver manager and the JDBC drivers. The driver manager can support multiple drivers connecting to different databases. The JDBC drivers can be entirely written in Java so that they can be downloaded as part of an applet, or they can be implemented using native methods to bridge to existing database access libraries.

Oracle JDBC Drivers

Oracle provides three types of JDBC drivers, which you can use for different types of applications:

  • Oracle thin JDBC driver: This driver is written completely in Java and is only 900KB (compressed), making it ideal for Java applets that can be used with a browser. When you download an applet from an HTML page, the thin JDBC driver is downloaded with it. A direct Net8 connection is established between the applet and database. Scalability is provided with the use of the Net8 connection manager.
  • Oracle JDBC/OCI driver: This driver uses Oracle client libraries such as OCILIB, CORE, and Net8 to provide OCI calls to access the database. You must perform client installation of the JDBC/OCI driver because it is not downloadable. This driver can be used for client/server Java applications, as well as middle-tier Java applications running in a Java application server. However, these JDBC/OCI drivers can't be used with applets.
  • Oracle JDBC Server Driver: The JDBC Server Driver (also referred to as KPRB driver) enables Java programs to use the Oracle8i Java Virtual Machine. The Server Driver runs inside the database to communicate with the SQLEngine. No network round trips are involved because the Server Driver and the SQLEngine both run in the same address space. This driver is for server-side use only and provides server-side JDBC support for any Java program used in the database, Java stored procedure, and Enterprise Java Beans (EJB). In addition, it enables communication with SQL and PL/SQL programs.

Choosing the Appropriate Driver

You should consider some factors when choosing among the various drivers for your application or applet:

  • If you are writing an applet, you must use the JDBC thin driver because the JDBC OCI-based driver classes cannot be downloaded to a Web browser.
  • If you need to connect to your Oracle8i data server using an application or an applet, you should choose the JDBC thin driver.
  • If you desire maximum performance from your application, then you should use the JDBC OCI driver.
  • If your Java program is running in the Oracle database server using at least the Oracle 8.1.5 Java VM, you should choose the JDBC Server driver.

To read the rest of this article and to view the accompanying tables, click over to InformIT. Registration is required, but it's free.

For More Information

Next Steps

Want to learn more about data persistence and JDBC? Check out these interesting articles:

Dig Deeper on Oracle database design and architecture

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.