If you're using JNDI to connect to your database through Tomcat, then it's possible you've had to deal with database connection pool leaks. Your code tests fine, it's been reviewed, but in load tests or in production your app is unable to acquire database connections, the pool is empty!
Fear not, there are some handy parameters which can be set in your application's XML configuration file (in tomcat/conf/Catalina/YOUR_IP/YOUR_APP.xml):
removeAbandoned: Enables automated monitoring of pooled DB connections, and closes them if they time out. This is a catch-all, which prevents bugs in your code from bringing a system to its knees. If your app fails to close a connection, this will close it after a certain time period.
removeAbandonedTimeout: Sets the timeout value for use with the removeAbandonded parameter.
logAbandoned: Logs stack trace information when a pooled DB connection times out. This is invaluable information which can help you quickly track down the offending lines of code which failed to close the connection.
These helpful parameters are documented here on the Apache Tomcat site, along with many other hints and suggestions.
Posted by Vance