I have a web application written in Struts that makes many database transactions.
The application works fine for a while, but after several days, it starts hanging on the DataSource.getConnection() method. I assume this means all the connections have been used, and it's waiting for a connection to become available.
In each database method, there is code similar to this:
In MySQL, max_connections=256, so it seems to me that the connections are not being closed after they're opened. I don't see how that can happen though, since the connection is closed in the finally clause. I verified that every connection in my code is closed in the manner shown above.
To get it working again, I have to killall -9 java, and restart the web application.
Any ideas?
The application works fine for a while, but after several days, it starts hanging on the DataSource.getConnection() method. I assume this means all the connections have been used, and it's waiting for a connection to become available.
In each database method, there is code similar to this:
Code:
Connection con = null;
try {
con = dataSource.getConnection();
//Do database stuff
} finally {
if (con != null)
con.close();
}
In MySQL, max_connections=256, so it seems to me that the connections are not being closed after they're opened. I don't see how that can happen though, since the connection is closed in the finally clause. I verified that every connection in my code is closed in the manner shown above.
To get it working again, I have to killall -9 java, and restart the web application.
Any ideas?