I am working on a legacy web application that issues jdbc commands from jsps. The jdbc database connection is issued once in the beginning from some java initialization code.
After awhile, the database access gets very slow. I fear that the connection is never closed when the user logs out or an exception is thrown. Where should I close the database connection without using connection pooling?
If I have to use connection pooling, what product would you recommend?
so let me check what you are saying.
The database connection is opened when the webapp is started and the same connection is used all the time until the webapp is shut down?
Or is it just once per session?
so i bet whoever designed this didn't think to close any statement or result sets.
Finding and closing every statement, prepared statement and result set in a finally block, would be the very first thing to do.
and close the connection whenever it is finished with would be the second job.
Joined: Jan 13, 2009
The connection is obtained when the webapp comes up and stored in the servletContext.
Most of the statements have been closed (I closed the the ones that weren't)...none of the resultsets have been closed. The same ResultSet object is used for a given jsp.
Since the same connection is used for all clients, would you recommend using a connection pool?