Chapter 2.  Application Database Connections

In Chapter 1, I defined four client types. In this chapter, I’ll discuss how to make a database connection from the first type of client, an application. Establishing a database connection may sound like an easy task, but it’s often not, because you lack the necessary information. In this chapter, I’ll not only explain the ins and outs of making a connection but also talk about the different types of connections you can make and point out the advantages of each.

JDBC Drivers

In order to connect a Java application to a database using JDBC, you need to use a JDBC driver. This driver acts as an intermediary between your application and the database. There are actually several types of JDBC drivers available, so you need to choose the one that best suits your particular circumstances. You also need to be aware that not all driver types are supported by Oracle, and even when a driver type is supported by Oracle, it may not be supported by all versions of Oracle.

Driver Types

Sun has defined four categories of JDBC drivers. The categories delineate the differences in architecture for the drivers. One difference between architectures lies in whether a given driver is implemented in native code or in Java code. By native code, I mean whatever machine code is supported by a particular hardware configuration. For example, a driver may be written in C and then compiled to run on a specific hardware platform. Another difference lies in how the driver ...

Get Java Programming with Oracle JDBC now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.