I am using Tomcat 5.0, and java JDK 1.4 to connect to Oracle 9 using the default connection pooling (org.apache.commons.dbcp.BasicDataSourceFactory).

This all works fine and dandy but I do have a problem that I need to resolve.

When I first try to get a connection, if, for some reason this cannot be done, and I receive a SQLException, then it never subsequently works - let me explain further...

When my machine boots up Oracle starts, then Tomcat starts. If somebody accesses Tomcat it tries to get a connection to Oracle. If Oracle has not finished initialising then the getConnection throws a SQLException - (Oracle initialising or shutting down) - which is fair enough. So I reset my InitialContext and DataSource to null. If I try again a little later (after I know Oracle is ready and waiting) I still get the same error even though Oracle is ready. It's as though something needs to be reset, but I don't know what. The only way around this problem is for me to manually stop and restart Tomcat.

I know I can't be the only person in the world with this problem - has anybody out there found a solution?