I have DatasourceRealm configured in Tomcat 5.5.7. The user roles, passwords etc are in my database and I am using Basic authentication. So, a user tries to access a resource, prompted for credentials, log on etc. This works fine but eventually the number of maxActive connections are reached, 15 in my case when it shouldn't be. The problem seems to be that the connections are not being closed. How do the authentication connections get closed in tomcat? Is it related to the session expiry time, or is there a parameter that can be added to the datasource declaration to do this?
But I don't create the connections within my code. It's going on behind the scenes in Tomcat. It authenticates users based on the user roles etc within my database and obtains a connection to the database to do that, from the data source declaration.
craig a chapman
Greenhorn
Joined: Jun 24, 2005
Posts: 27
posted
0
The "InactivityTimeout" parameter doesn't appear to work. I'm monitoring the connections through MySQL administrator. I would expect the number of connections to decrease with inactivity but they all remain open. I've only seen that parameter mentioned when setting up DataSource pools with Orion, with a quick search in google.
Not doing so is one of the more common causes of memory leaks in servlet apps. [ November 03, 2005: Message edited by: Ben Souther ]
eve agostini
Ranch Hand
Joined: Nov 01, 2005
Posts: 43
posted
0
thank you craig!! now it works! merci beacoup!!grazie grazie!
craig a chapman
Greenhorn
Joined: Jun 24, 2005
Posts: 27
posted
0
I know that closing db connections returns them to the pool and anywhere in my code that I am finished with an open connection, I do so. I am aware of the consequences of not closing connections, result sets etc.
But, the authentication is performed by Tomcat. It uses the DataSourceRealm settings to obtain a connection to the database to authenticate users. I don't explicitly open a connection anywhere in my code to do this, so I cannot explicitly close the connection. Surely theres a parameter, such as the one Ulf mentioned that tells the pool to close any connections that have not been utilised in a specified time, thus returning them to the pool. If you can configure Tomcat to open a connection to the database to authenticate users, there must be a corresponding close option, I would have thought.