O'Reilly logo

Java Database Best Practices 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

Chapter 11. JDBC

These common thoughts are expressed in a shared public language, consisting of shared signs... a sign has a “sense” that fixes the reference and is “grasped by everybody” who knows the language...

Noam Chomsky, Language and Thought

JDBC is one of the oldest programming APIs in the Java platform. In fact, it is the first of the enterprise APIs that eventually became the J2EE platform. Its goal is to create a shared public language for Java access to any database engine.

SQL lies at the heart of the JDBC API. I therefore assume a basic knowledge of SQL in this chapter. Chapter 10 contains a SQL tutorial if you need some background.

Architecture

Working with leaders in the database field, Sun developed JDBC as a unified API for database access. As part of the JDBC design process, they kept in mind three main goals:

  • JDBC should be an SQL-level API.

  • JDBC should capitalize on the experience of existing database APIs.

  • JDBC should be relatively simple.

As an SQL-level API, JDBC enables you to construct SQL statements and embed them inside API calls. You are essentially using JDBC to make a smooth transition between the SQL and Java. Your application sends a query to the database as SQL and gets the results back through a Java object. Any database error you encounter is thrown to your application as a Java exception.

Database programming in most languages today is very different from what it was just seven years ago. It used to be that each database engine had its own proprietary ...

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