Friday, November 02, 2007

Apache DbUtils Completely Useless

I am disappointed about the Jarkarta Commons DbUtils project. I give a link to it, because it's a bad project (even if written in clean code). It is very simple, but it really does not do much for you.

I was looking for a very simple abstraction of JDBC. I thought bringing Spring in my project would be overkill. After trying DbUtils, I think again. It does not help. It does not handle frequent cases well, and it does not save many lines of code.

I am a bit angry about it as I noticed that by using it, my test program that was taking 2s with straight JDBC before is now using 1 minute!

The reason behind this huge performance penalty is that there is no way to just reuse a PreparedStatement with the existing classes. For each query with a same sql, it will create a new PreparedStatement object, even if you reuse the connection. I am surprised since this is probably why PreparedStatement is used in the first place. How can such a project be part of Jakarta repository?

Now I just wish Spring was more Guice like, maybe I should write a Spring JDBC like layer for Guice.

2 comments :

  1. ibatis http://ibatis.apache.org/ is a great JDBC abstraction framework. It's very simple,lightweight and effective and doesn't try to do ORM. You should take a look if you aren't already familiar.

    ReplyDelete
  2. Dear,

    I found your post by asking the same question; why there is no preparestatement cache in that lib.
    However the behaviour is easy to implement. Just extends the class QueryRunner and override prepareStatement.

    Nicolas FRANCOIS

    ReplyDelete