File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes DBCP issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "DBCP issue" Watch "DBCP issue" New topic

DBCP issue

Wim Folkerts

Joined: Mar 10, 2010
Posts: 19


We've been migrated to the DBCP connection setup of Apache via JNDI lookup and use the connection setup like described on the site:

The reason of this migration is because the existing OracleConnectionPoolDataSource object (oracle.jdbc.pool.OracleConnectionPoolDataSource) was not thread safe. See explanation on the site:

The DBCP implementation solved this problem, but now I facing the following issue; I run the webapplication without any problem. However the next day I suddenly have the following error:

After refresh:

After the next refresh:

When I refresh the site again, I got the web application back again.

We're using the following configuration:
- Tomcat 6.0.14
- JDK 1.6.0_14
- The ojdbc14.jar, ojdbc14dms.jar and orai18n.jar (from Oracle 10g) are in the %TOMCAT_HOME%/lib folder

Can anyone help me with this issue?

Regards Wim
Jelle Klap

Joined: Mar 10, 2008
Posts: 1951

That problem could be related to idle connections being cleaned up.
DBCP should allow you to configure it to test and reallocate idle connections if necessary.

Try playing around with the testOnBorrow / testOnReturn / testWhileIdle etc. properties and see if that solves the problem.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Wim Folkerts

Joined: Mar 10, 2010
Posts: 19

Thanks Jelle, I'll look into those properties.

I configured the DBCP properties in that way that abandoned connections are removed and logged, see below:
Wim Folkerts

Joined: Mar 10, 2010
Posts: 19


I've just changed the DBCP configuration and after I wait a day, I didnt get the issue I previously had. Once in 30 minutes it checks for max 3 connections if it is still valid. If no, it will be removed from the pool which solves the stale connection problem. Below a part of this testOnBorrow config:

So it looks like this issue has been resolved!
I agree. Here's the link:
subject: DBCP issue
It's not a secret anymore!