Does SQL recycle connections?

  • I have MS SQL 2005 Standard edition running and Tomcat 6 web server running. My company's java application is hitting the SQL database. I have recently began doing some performance testing on the database and one thing I have found, there are alot of open connections left there doing nothing when no one is using the application. I thought that after the session had ended in the application, SQL would kill the connection after a specified period. Is there a way to force SQL to kill the connections being left inactive?

    Hope someone can help.

    Thanks.

  • No, SQL does not kill inactive connections. You could do this manually, but it is really a sign of an application problem that you should fix.

    Your application or web server, or application pool, or ADO - something is leaving connections open. This could be because you have connection pooling turned on somewhere or it could be that your application has not been programmed to close connections everywhere.

    It would be best to fix the application layer holding open connections rather than forcibly closing them on the database end. It could lead you to either getting some pooling setting correct, or (probably more likely) get you to a memory leak in your application being caused by not cleaning up objects everywhere.

  • Thanks for responding. We do have connection pooling enabled in our web application at the request of a client. Is that a best practice?

    Yeah I think I'll have to discuss this with my developer and get him to close the connections in code after they are used.

  • Sometimes connection pooling is good and sometimes it is not.

    Absolutely make sure your developer is closing connections - pooling or not. If the connections are not closed, they never get put back on the shelf for pooling.

    As for your application using pooling - it may be a good thing. It is of real benefit if you have a lot of connecting and disconnecting. If you get a connection from the pool, it does not have to reconnect to the database. It can cause some security issues though, so you need to understand it.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply