The JDBC Architecture

We have already mentioned that JDBC is a set of interfaces implemented by different vendors. Figure 13-1 shows how database access works from an application’s perspective. Essentially, the application simply makes method calls to the JDBC interfaces. Under the hood, the implementation being used by that application performs the actual database calls.

The JDBC architecture
Figure 13-1. The JDBC architecture

JDBC is divided into two Java packages: java.sql and javax.sql . The java.sql package was the original package that contained all the JDBC classes and interfaces. JDBC 2.0, however, introduced something called the JDBC Optional Package—the javax.sql package—with interfaces that a driver does not have to implement. In fact, the interfaces themselves are not even part of the J2SE as of JDK 1.3 (though it has always been part of the J2EE).

As it turns out, some of the functionality in the JDBC Optional Package is so important that it is no longer “optional” and should instead be part of the J2SE with the release of JDK 1.4. For backwards compatibility, the Optional Package classes remain in javax.sql.

Get Managing & Using MySQL, 2nd 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.