I have set a JDBCRealm
for web-app inside tomcat, and when I reload it I got this from tomcat:
SEVERE: A web application registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped开发者_如何学JAVA. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
I use tomcat 6.0.24, with MySQL Connector 5.1.10,,,
Is there a way to clean it up, so tomcat won't display SEVERE
message?
This is not a leak, or at least it is one that does not matter. If you have a singleton object (The JDBC driver) and it is never released until the app finishes, does it matter ?
The database will close any pending connections after a given amount of time.
If it really bothers you, you could fix it by overriding close method this way:
public class XBasicDataSource extends BasicDataSource {
@Override
public synchronized void close() throws SQLException {
DriverManager.deregisterDriver(DriverManager.getDriver(url));
super.close();
}
}
And use your XBasicDataSource .
精彩评论