Chapter 8. JDBC

The JDBC[35] API provides Java applications with midlevel access to most database systems, via the Structured Query Language (SQL). JDBC is a key enterprise API, as it’s hard to imagine an enterprise application that doesn’t use a database in some way.

In the first two editions of this book, we focused on the original JDBC 1.0 and 2.0 APIs. As of J2SE 1.4, the JDBC 3.0 API became part of the standard Java deployment, so we’ve reworked this chapter to focus on the JDBC 3.0 API, which includes a modest yet valuable set of new features. Some JDBC 3.0 features aren’t yet widely implemented (or aren’t supported by some underlying databases ), so we’ll call special attention to them.

Since JDBC has been around for so long (it even predates the J2EE abbreviation), the different versions can get a little confusing. A number of JDBC 2.0 features were found in the JDBC 2.0 Optional Package and distributed as part of the javax.sql package rather than regular JDBC’s java.sql package. JDBC 3.0 has merged everything back into a single specification, where it will hopefully remain.

A word of caution: while the java.sql package is not tremendously complex, it does require grounding in general database concepts and the SQL language itself. This book includes a brief SQL reference (see Appendix D), but if you have never worked with a relational database system before, this chapter is not the place to start. For a more complete treatment of JDBC and general database concepts, we recommend ...

Get Java Enterprise in a Nutshell, Third Edition 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.