9.7 Beyond the Core

Java Servlet Programming, 2nd Edition > 9. Database Connectivity > 9.7 Beyond the Core

 
< BACKCONTINUE >

9.7 Beyond the Core

In addition to the core JDBC methods and techniques covered in this chapter, there are additional database APIs available that help in writing complicated database-access applications. One such API is JDBC 2.0, the follow-on to JDBC 1.2 discussed throughout this chapter.

At the time of this writing, JDBC 2.0 has yet to be widely implemented and used. To employ JDBC 2.0 requires both a database that supports its advanced features and a driver that grants access to those features. Luckily, you'll find JDBC 2.0 support in all J2EE servers because any server wishing to be J2EE complaint is required to provide access to a JDBC 2.0 database and driver. The J2EE reference implementation from Sun, for example, comes bundled with an evaluation copy of the Java-based Cloudscape database.

JDBC 2.0 comes in two parts. One part resides in the java.sql package of Java 2 and is required to be supported by any JDBC 2.0-compliant database and driver. The other part resides in the javax.sql package. This Optional Package contains several features which may be implemented by a JDBC 2.0-compliant database and driver but are not required.

Among the enhancements in the core java.sql package are scrollable and modifiable result sets. These two features allow the ResultSet cursor to be moved forward and backward arbitrarily (instead of just forward one row at a time), with the cursor able to change, insert, and delete rows along the way. Core support has also been added for new SQL3 data types (including BLOB for binary large objects, CLOB for character large objects, and ARRAY for arrays) and for batch updates that allow several update statements to be sent to the server with one network request.

The javax.sql Optional Package includes many features that are especially important to enterprise applications. One such feature is JNDI lookup support. This allows a database connection to be retrieved by name from a JNDI server. Another feature is built-in connection pooling, something that hardly changes the API but allows a preexisting connection to be retrieved. An extremely important optional feature in JDBC 2.0 is support for distributed transactions. This allows a transaction to be spread between multiple separate databases, updating both databases with one atomic operation. Finally, JDBC 2.0 includes support for RowSet objects that wrap ResultSet row data allowing easy caching of data and easy transfer of data across a network, as well as standardized access to any tabular data source such as a spreadsheet or flat file.

More information on JDBC 2.0 features can be found in Database Programming with JDBC and Java by George Reese (O'Reilly) and JDBC API Tutorial and Reference,by Seth White et al. (Addison-Wesley) and in the online tutorials available at http://java.sun.com/products/jdbc.

Finally, for those who prefer to think in higher-level terms than JDBC provides, a company called Clear Ink sponsors an open source (Apache-license) library called Village that sits above JDBC 1.2 and exposes an API that simplifies interaction with the database. It's directly modeled after the dbKona commercial product from BEA/WebLogic. Others have built on top of Village to produce a more robust version named Town. Both Village and Town are available at http://www.working-dogs.com. (No news yet on City.)


Last updated on 3/20/2003
Java Servlet Programming, 2nd Edition, © 2001 O'Reilly

< BACKCONTINUE >


Java servlet programming
Java Servlet Programming (Java Series)
ISBN: 0596000405
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net