InfoQ

News

Easier Database Development with JDBC 4.0

Posted by Scott Delap on Aug 04, 2006 04:04 PM

Community
Java
Topics
Data Access
Tags
JDBC
Java 6.0 will include a number of Java Database Connectivity enhancements collectively known as JDBC 4.0. One of the main goals of JDBC 4.0 was to try and reduce the amount of boilerplate JDBC code a developer had to write. With this in mind a number of enhancements were made including:

  • Auto-loading of JDBC driver class
  • Connection management enhancements
  • Support for RowId SQL type
  • DataSet implementation of SQL using Annotations
  • SQL exception handling enhancements
  • SQL XML support

The DriverManager class can now lookup the appropriate database driver using the Java SE Service Provider included in Java 6.0. Class.forName() is no longer needed. The SQLException class has also been enhanced to support nested cause exceptions, next exceptions (when two SQLExceptions may be thrown at a time), and foreach support for iterating over exceptions. Blogger Patrick Lightbody noted "I could see JDBC 4.0 replacing my need for iBatis" after reading another blog post on JDBC 4.0 functionality. JDBC 4.0 includes basic O/R mapper functionality that eases the repetitive task of copying ResultSet data into objects. It does not handle inheritance or table relations however.

4 comments

Reply

I wish. by Clinton Begin Posted Aug 6, 2006 1:27 AM
Re: I wish. by Patrick Lightbody Posted Aug 6, 2006 8:42 AM
Re: I wish. by Cameron Purdy Posted Aug 6, 2006 11:14 AM
Re: I wish. by Javier Pavier Posted Aug 6, 2006 12:18 PM
  1. Back to top

    I wish.

    Aug 6, 2006 1:27 AM by Clinton Begin

    I wish Patrick was right. However, I bet the JDBC 4 features highlighted above will be generally useless for all but the simplest applications. First, it will take way too long to get it out. Second it will take way too long for any significant market share to adopt (JDK 5 is still only about 15 - 20% adoption). Finally, Sun/JCP won't have the courage to take it as far as they'd need to in order to make it competetive with iBATIS, Hibernate or any other persistence solution. I have little faith. DISCLAIMER: I'm obviously biased. But, I'm entitled to an opinion anyway... ;-)

  2. Back to top

    Re: I wish.

    Aug 6, 2006 8:42 AM by Patrick Lightbody

    Clinton, You're probably right, but we can hope :) I love iBatis - I hope you don't take my comment the wrong way. I'd love to see something like that (like parts of what JDBC 4.0 seems to offer) built in to the JDK.

  3. Back to top

    Re: I wish.

    Aug 6, 2006 11:14 AM by Cameron Purdy

    JDBC's verboseness never bothered me .. the problems that bothered me were its lack of support for the full set of ANSI SQL "1992" types (let alone more contemporary standards!), e.g. date/time intervals, etc. I always figure that low level specs are a pain because they attempt to solve the 98/2 principle, which is why things like Spring or iBatis are handy for solving the 80/20 principle. Peace, Cameron Purdy Tangosol Coherence: The Java Data Grid

  4. Back to top

    Re: I wish.

    Aug 6, 2006 12:18 PM by Javier Pavier

    ... and if the lack of support in the spec wasn't bad enough, what are worse are the appalling attempts at JDBC drivers in existence (many methods "not implemented", returning extremely dubious interpretations of the spec (failing in the spec for not being specific), or using custom types to try to lock you into their own RDBMS).

Exclusive Content

Rationalizing the Presentation Tier

Thin client paradigm characterized by web applications is a kludge that needs to be repudiated. Old compromises are no longer needed and it's time to move the presentation tier to where it belongs.

Agile Project Management: Lessons Learned at Google

In this presentation filmed during QCon 2007, Jeff Sutherland, the creator of Scrum, talks about his visit at Google to do an analysis of Google's first implementation of Scrum.

AtomServer – The Power of Publishing for Data Distribution

In this article, Bryon Jacob and Chris Berry introduce AtomServer, their implementation of a full-fledged Atom Store based on Apache Abdera, which is now available as open source.

An Introduction to Virtualization

It is easy to think that virtualization applies only to servers. In reality the recent resurgence of the concept is also being applied to networking, storage, and application infrastructure.

REST Anti-Patterns

In this article, Stefan Tilkov explains some of the most common anti-patterns found in applications that claim to follow a "RESTful" design and suggests ways to avoid them.

Choosing between Routing and Orchestration in an ESB

In this article, Adrien Louis and Marc Dutoo discuss the differences and relative merits of using orchestration vs. routing in a typical ESB setup, and discuss various implementation options.

Enterprise Batch Processing with Spring

Wayne Lund discusses batch processing, Spring Batch objectives and features, scenarios for usage, Spring Batch architecture, scaling, example code, failures and retrying, and the future roadmap.

User Story Estimation Techniques

Developer Jay Fields draws on his experiences as a ThoughtWorks consultant to describe effective user story estimation techniques.