| Previous | Table of Contents | Next |
Java Database Connectivity (JDBC) is an application programming interface (API) that describes a standard Java library for accessing data sources, primarily relational databases, that use the Structured Query Language (SQL). JDBC is JavaSofts answer to the corporate developers requirement for database access from an enterprise Java application. Not only does JDBC provide a standard API for accessing data sources such as relational databases, but it also provides a standard architecture for database vendors so they can provide data source drivers. These drivers allow access to the vendors products directly from your Java applications.
NOTE: In May 1998, Sun released the JDBC 2.0 specification. The discussions in this book mostly refer to the JDBC 1.0 specification because few drivers support 2.0 at this time. Where appropriate, JDBC 2.0 features and enhancements are identified.
This chapter describes the goals and architecture of JDBC. It assumes you are familiar with relational database theory and SQL. If you are not familiar with SQL, you may want to read one of the many available SQL books such as A Visual Introduction to SQL by J. Harvey Trimble and David Chappell.
Although SQL is an ANSI standard language used to manage relational databases, each database vendor implements its own slightly unique version of SQL to take advantage of database-specific features. In order for application developers to access various databases without having to learn an entirely new database access library each time, standard specifications for database access drivers (sometimes referred to as bridges) have emerged. These standards allow developers to build applications that can access, view, and modify data from multiple, diverse databases as well as easily port new and existing applications to new data sources. The bridge acts as a translator that takes generic database access calls and translates them to database-specific calls. The most common driver specification is ODBC, or Open Database Connectivity. ODBC is a C- based standard developed by the SQL Access Group (SAG) standards committee and popularized by Microsoft. ODBC is based on the Call Level Interface (CLI) specification of SAG.
NOTE: In 1995, SAG joined with the X/Open Data Management Technical Committee to form the X/Open SQL Access Group. This group is composed of representatives from AT&T, Inprise, Computer Associates, IBM, Informix, INTERSOLV, Microsoft Corporation, Oracle Corporation, Progress, Sybase, Visigenic Software, and other vendors.
ODBC allows users to access data in a relational database management system. ODBC provides a consistent interface for communicating with a database. However, the standard suffers from several drawbacks. Developers have complained that ODBC is slow and limited in functionality. Another problem is that ODBC drivers are platform specific. This means if you write your application to run on multiple platforms, you will need a separate driver for each platform, which makes your application less portable.
NOTE: You can find more information on ODBC at www.microsoft.com/data/odbc/.
Like ODBC, JDBC uses drivers to create a bridge to a specific database. Because JDBC drivers are still being developed for many databases, you can use the JDBC/ODBC bridge from JavaSoft to act as your database driver until a native driver is available.
NOTE: For a list of available JDBC drivers and vendors supplying them, check http://java.sun.com/products/jdbc/jdbc.drivers.html.
ODBC is more mature than JDBC, so there are drivers for accessing most databases through ODBC. The JDBC/ODBC bridge allows you to use a native Java interface to access your database through ODBC without having to learn the ODBC specification. This extra overhead does create some performance issues, and ODBC is not as rich a specification as JDBC; therefore you cant take full advantage of all of JDBCs capabilities with this driver. However, this technique will allow you to get up and running while the vendors continue to develop and deliver database-specific JDBC drivers. For most of the JDBC chapters in this book, we use the JDBC/ODBC bridge in our examples. It is free from JavaSoft and will work with most databases you may have access to, provided you have the appropriate ODBC driver.
JDBC was modeled after the ODBC architecture. The JDBC developers had two high-level goals for its design: adhering to common database standards and keeping the API simple.
Java programmers use JDBC for most database access calls. The JDBC API is designed to allow application programmers to communicate with any data source that has a JDBC driver implementation. In order to talk to various data sources, the API must remain fairly generic. However, the goal is to replace the functionality of ODBC in C-based applications and specifically provide interaction with SQL databases. This goal is met in three ways:
Supporting common standards enables enterprise developers to take advantage of the latest Java technologies while maintaining a high degree of interoperability with other industry-standard products. JDBC solves most relational database access requirements from Java.
| Previous | Table of Contents | Next |