Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Easier Database Development with JDBC 4.0

Easier Database Development with JDBC 4.0

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.

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • I wish.

    by Clinton Begin,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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... ;-)

  • Re: I wish.

    by Patrick Lightbody,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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.

  • Re: I wish.

    by Cameron Purdy,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    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.


    Cameron Purdy
    Tangosol Coherence: The Java Data Grid

  • Re: I wish.

    by Javier Pavier,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    ... 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).

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p