This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Servlets and the fly likes connection hangs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "connection hangs" Watch "connection hangs" New topic

connection hangs

Peter Straw
Ranch Hand

Joined: Jan 08, 2002
Posts: 79
I have a servlet that connects to a database no problem when tomcat has been recently re-started, but after some time has elapsed, even if there aren't any users on the system, it takes a very long time to get a connection object and eventually just fails completely. Does anyone know what this might be please? Or suggest ways I might be able to de-bug the problem. I'm using tomcat4 on linux, the database is on a remote box from the webapp
Many thanks.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
are you closing and releasing your connections ?? Maybe you should use a connection pool (of your container or some free) to handle your connections and don't do that directly in your servlet.
Peter Straw
Ranch Hand

Joined: Jan 08, 2002
Posts: 79
yes I'm closing the ResultSet, Statement and Connections. I'm using the dbcp connection pool from the Jakarta Commons package but I'm not sure that it's a problem with the pool as it happens on another site I'm writing that doesn't use pooling.
I agree. Here's the link:
subject: connection hangs
It's not a secret anymore!