The Artima Developer Community
Sponsored Link

Java Buzz Forum
jDBI Releases Galore

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
jDBI Releases Galore Posted: Jan 18, 2005 8:35 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: jDBI Releases Galore
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

I have been lax in announcing jDBI related stuff -- time to make up for that =) First, jDBI made its 14th and 15th (1.1.2 and 1.2.1 -- seperate branches). Technically 1.2 maintains bytecode compatibility with 1.1 (you can drop the jar in and go) but there is a huge seven character difference. DBIException now extends RuntimeException per a bunch of strong arguments by Patrick Burleson. Seven characters, world of difference. Guess I have taken the dive into optional exception checking. Water still feels chilly.

Aside from API changes, hosting has moved to the Haus. The subversion repo isn't there yet, but the rest is. No pretty confluenze site (yet?). We also have mailing lists! I should probably post them on the site sometime soon... In the mean time, its not hard to figure out my email address, or the lists if you look at how Bob lays out projects ;-)

As the last release I announced was 1.0.X series, some other big things in there include really nice Spring integration (factory bean which makes a couple minor changes to play as expected and hooks into the platform transaction system, and DBIUtils to provide transactionally bound handles/access/etc)

Meeting a few feature requests there is a really nice batch and prepared batch system with usages looking something like:

public void testBatchOfTwo() throws Exception
{
    handle.batch()
            .add("insert into something (id, name) values (1, 'one')")
            .add("insert into something (id, name) values (2, 'two')")
            .execute();

    final Collection results = handle.query("select id, name from something order by id");
    assertEquals(2, results.size());
}

public void testPreparedBatch() throws Exception
{
    handle.prepareBatch("insert into something (id, name) values (:id, :name)")
            .add(new Something(1, "one"))
            .add(new Something(2, "two"))
            .add(new Something(3, "three"))
            .add(new Something(4, "four"))
            .execute();
    assertEquals(4, handle.query("select * from something").size());
}

public void testPreparedBatch2() throws Exception
{
    final Something[] things = new Something[]
    {
        new Something(1, "one"),
        new Something(2, "two"),
        new Something(3, "three"),
        new Something(4, "four")
    };
    handle.prepareBatch("insert into something (id, name) values (:id, :name)")
            .addAll(things)
            .execute();
    assertEquals(4, handle.query("select * from something").size());
}

That one is my favorite. I rarely used batched sql when working with jdbc directly as, well, it is bloody inconvenient. Do it all the time now =)

A particularly fun piece is not actually released yet as I am not satisfied that I have caught all the edge cases -- Henri Yandell asked for in-clause expansion. That is, bind a collection or array to a single formal param for an sql in clause, a la, select id, name from something where id in ?, which could have a List<Long> bound and would expand as required to behave correctly (ideally as a prepared statement still). As I said, I have code which does it, but it is buried in subversion and not exposed yet as I had wanted to avoid fulling parsing and transforming the sql. Still, that is powerful stuff, so it'll probably be the next significant feature.

Anyway, enjoy it and have fun! Remember, SQL isn't teh ev1l, JDBC is just inconvenient! Let the code do the work =)

Read: jDBI Releases Galore

Topic: Gmail Invites Previous Topic   Next Topic Topic: Professional Swing: Threading

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use