Less 'Crap Code'

I recently wrote about how developers don’t always clean up correctly when using databases after I read this blog.

In my blog entry I suggested that developers could use a library (such as Spring) to help them close up database resources. Well, today I stumbled across the Java Specialists Newsletter Issue 116 which details another library. The Jakarta Commons-DbUtils library does this for you.

From the commons web site "DbUtils is a small set of classes designed to make working with JDBC easier. JDBC resource cleanup code is mundane, error prone work so these classes abstract out all of the cleanup tasks from your code leaving you with what you really wanted to do with JDBC in the first place: query and update data

If you are using JDBC for your persistence access, I recommend that you use one of these available libraries (DbUtils or Spring etc.). After all, writing JDBC code is fairly tedious and error prone.