views:

60

answers:

1

I see that some people use org.apache.commons.dbcp.BasicDataSource while other configurations have com.mchange.v2.c3p0.ComboPooledDataSource.

Spring has its own: org.springframework.jdbc.datasource.DriverManagerDataSource

There are probably even more. But which one is best? I have a JPA/Hibernate three tier application that needs connection pooling, but it looks like that all support this....

+1  A: 

Spring has its own: org.springframework.jdbc.datasource.DriverManagerDataSource

The class org.springframework.jdbc.datasource.DriverManagerDataSource implements the DataSource interface but is NOT a connection pool, it's just a convenient class that and can be used during development instead of a real pool (but it creates a new connection on every call). I'd suggest to read its javadoc.

I have a JPA/Hibernate three tier application that needs connection pooling, but it looks like that all support this....

If you are using an application server, favor the connection pool of your application server.

If you are not, then DBCP, C3P0 are the most common solutions. I would use C3P0 (which is actually bundled with Hibernate now instead of DBCP), I faced some deadlock issues with DBPC under high load, not with C3P0 so I tend to prefer C3P0.

It may be worth noting that DBCP has been resurrected very recently after a very long period of inactivity (while C3P0 is inactive) and might thus get better.

Other players include Proxool and BoneCP (a recent new competitor). The later looks interesting but I don't have any practical experience with it.

In any case, you should typically run robustness tests before going to production.

See also

Pascal Thivent