Shayan
Shayan

Reputation: 2828

How to use Java JDBC connection pool?

I want to use a JDBC connection pool. The most important factor is that it's easy-to-use and bug-free. What is suitable for me?

Upvotes: 11

Views: 6376

Answers (5)

egerardus
egerardus

Reputation: 11486

2 years later... Just migrated to jdbc-pool (standard on Tomcat 7 now) it was very easy to implement it standalone in a web app or for the the whole server. Per specifications and my experience it out-performs c3p0.

Per specs it is also alot cleaner than dbcp or c3p0.

Upvotes: 1

wwadge
wwadge

Reputation: 3544

Also have a look at BoneCP; there are some samples on the site.

Upvotes: 8

Pascal Thivent
Pascal Thivent

Reputation: 570565

I suggest c3p0 (over DBCP which has some really serious issues): it works great, is actively maintained and easy to use. Maybe have a look at this previous question for more inputs on this.

Update: I admit I didn't check the status when I wrote this answer (I'm using c3p0 for many years and was happy with it) and it appears that c3p0 development is in stand by. Funnily, the previous question mentioned as reference has been updated the 2010-03-12 to mention that DBCP development is alive again. My original post may thus be out of date.

Upvotes: 7

trashgod
trashgod

Reputation: 205885

I've used this MiniConnectionPoolManager with H2 and Derby.

Upvotes: 3

duffymo
duffymo

Reputation: 308998

Another fine alternative is the Apache Database Connection Pool.

Instead of getting a connection using DriverManager, you'll use a JNDI naming service to get your connection out of the pool.

Be sure to close your resources - Connection, Statement, and ResultSet. If you don't, your pool will be quickly exhausted.

Upvotes: 10

Related Questions