Guice JDBC and Pools

12 03 2010

These last days I’ve been working on a Rest application  which provides a generic interface to a database. So the idea are to provide a “REST” driver that can look into any given database. Since I needed look into any given table I could’nt use my ordinary stack with guice / warp persist and JPA. But had to create my own jdbc template (like spring jdbc template).  Doing db stuff one needs a connection pool and since C3P0 are somewhat dead (haven’t had a release in ages), I decided to go with Apache DBCP.

Im having one problem though if I use PoolableDatasource I get the dreaded “ Address already in use: connect”. If I manage the pool via the ObjectPool myself, it works like a charm. Not what I’ve hoped for.

Im wondering if it would be better (simpler) if I i used (Bone CP). I guess some one should make something like the Spring jdbc template for guice.

I’ve done some more testing and found out following things:

  • C3P0 are simple to setup, you can always owervrite defaults by property files or xml files
  • C3P0 are slower than Apache DBCP
  • Apache DBCP, pooled connection does not work or I am using it wrong
  • Bone CP, cannot connect to a jdbc uri with embedde password, user / password needs to be setup explicitly (which gives problems when using in memory hsql, no password / user)

For now I think i will be sticking to C3P0 since i gives the most clean implentation, although a little slower than the rest (we are talking miliseconds, for 150 concurrent users).

EDIT I need to revisit Bone CP since it has been updated and are now available in central repo 🙂




10 responses

6 07 2010
Simone Tripodi

Interesting one, good catch Nino!!!

29 09 2010
Wallace Wadge

“Bone CP, cannot connect to a jdbc uri with embedde password, user / password needs to be setup explicitly (which gives problems when using in memory hsql, no password / user)”

Can you please clarify this? If there’s an issue in connecting I will fix it ASAP.

(BoneCP author)

18 10 2010

Yeah, afair when it has problems when connecting to HSQL where theres no user / password needed to connect. Give it a try and you’ll see. I was really interested in using Bone CP, because it has the simplicity that I was looking for.

17 01 2011
Wallace Wadge

Sorry lost track of this thread!

Just for completeness sake, BoneCP can connect to any DB using either a username/pass combo or else just passes in any properties you want to the driver which should be accepted by HSQL.

Incidentally I always used to connect to HSQL via username = “sa” and no password.

22 10 2010
Simone Tripodi

@Wallace: I’d like to integrate BoneCP as well in the MyBatis-Guice (I’m the maintainer) subproject, but I didn’t find any reference on how to include it using Apache Maven… any hint?
In the case you still haven’t submitted to Maven Central Repo I can help you, having experienced it. Just let me know

17 01 2011
Wallace Wadge

Hi Simone,

Sorry didn’t get notifications for your post. BoneCP is built via maven but it’s not submitted to Maven Central yet (you need to add the site to your repositories list) — I’d like to take your offer for info re maven central submission 🙂

17 01 2011
Simone Tripodi

Hi Wallace,
how can I get in touch with you directly? Just give me a read-only svn access so I can submit a patch.
All the best,

25 01 2011
Wallace Wadge

Use wwadge at

Git repo is here:

though I’ll accept plain text emails too 🙂

1 02 2011
Simone Tripodi

Hi Nino,
update you poms, BoneCP is available in the Maven Central Repo!!! Congrats Wallace for the release!


3 02 2011

Cool ! 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: