aspose file tools*
The moose likes JDBC and the fly likes jdbc database connection (not being closed) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc database connection (not being closed)" Watch "jdbc database connection (not being closed)" New topic
Author

jdbc database connection (not being closed)

Ravi Danum
Ranch Hand

Joined: Jan 13, 2009
Posts: 104
Hello,

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?

Thanks for your help and time.

-ravi

Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1106

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.
Ravi Danum
Ranch Hand

Joined: Jan 13, 2009
Posts: 104
Wendy,

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?

Thanks.

Ravi
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jdbc database connection (not being closed)
 
Similar Threads
Connection Pooling
Connection pooling...?
Newbei : Websphere Connection Pooling
why should i use connection pooling ?
JDBC Connection Pooling Framework