Chapter 5. The JDBC Optional Package

Narrow souls I cannot abide;there’s almost no good or evil inside.

Friedrich Nietzsche, The Gay Science

The JDBC API you have covered in this book is called the JDBC 2.0 Core API. The JDBC 2.0 Core API is a narrowly focused specification that supports the functionality required by applications to successfully access databases. With the JDBC 2.0 release, however, Sun added an API called the JDBC 2.0 Optional Package (formerly called the JDBC 2.0 Standard Extension) to support extended database access functionality. The JDBC 2.0 version of the Optional Package encompasses the following elements:

  • Data source-oriented database access via the new JNDI API

  • JDBC driver-based connection pooling

  • Rowsets

  • Distributed transactions

As I write this chapter, the JDBC 2.0 Optional Package has just been finalized. Very few drivers support any of this functionality. I will therefore cover as much of the JDBC 2.0 Optional Package in this chapter as possible, but I will not be able to do full justice to some topics due to the scarcity of available information at the time of writing.

Data Sources

In Chapter 3, we covered how to register a JDBC driver and make a connection using a JDBC URL. Perhaps you, like me and many others, found this to be a bit of an annoyance, especially if you are trying to write database-independent code. I am now about to tell you that all of that is completely unnecessary. You don’t have to register drivers. You don’t have to know anything ...

Get Database Programming with JDBC & Java, Second 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.