O'Reilly logo

Database Programming with JDBC & Java, Second Edition by George Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Connecting to the Database

Now I am going to dive into the details about JDBC calls and how to use them. The examples in this book should run on your system regardless of the database or driver you use. The one phase when it is hard to achieve portability is the first step of connecting, because you have to specify a driver. I’ll discuss that first to get it out of the way.

Figure 3.4 shows how an application uses JDBC to talk to one or more databases without knowing the details concerning the driver implementation for that database. An application uses JDBC as an interface through which it passes all its database requests.

JDBC shields an application from the specifics of individual database implementations

Figure 3-4. JDBC shields an application from the specifics of individual database implementations

When you write a Java database applet or application, the only driver-specific information JDBC requires from you is the database URL. You can even have your application derive the URL at runtime—based on user input or applet parameters.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required