Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

What is wrong with my DBCP connection pooling implementation?

843859Jan 3 2008 — edited Jan 5 2008
Hello,

I've browsed that archives for info about DBCP connection pools, but I still can't figure out where I've gone astray. I'm using Java DB in a desktop application and want to create a Connection Pool because I'm accessing the database with multiple threads (I started bumping into ResultSet exceptions due to concurrency issues). I've basically been following the suggested implementations of the apache commons dbcp package. A summary for usage can be found here:

http://commons.apache.org/dbcp/apidocs/org/apache/commons/dbcp/package-summary.html

The relevant code that I grabbed from their summary is:
GenericObjectPool connectionPool = new GenericObjectPool(null);
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory("jdbc:some:connect:string", "username", "password");
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,connectionPool,null,null,false,true);
PoolingDriver driver = new PoolingDriver();
driver.registerPool("example",connectionPool);
When I grab a few connections from the database using the DriverManager.getConnection() method everything seems to work fine, but when I ran a test where I tried to grab 8 connections (without closing them), the application stalled. I'll be happy to provide full runnable code if this helps, but I thought I'd just ask with this preliminary info in case I'm simply suffering from a fundamental misunderstanding of how this works.

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 2 2008
Added on Jan 3 2008
7 comments
1,211 views