[英]MySQL create memory leak in Tomcat
I have set a JDBCRealm
for web-app inside tomcat, and when I reload it I got this from tomcat: 我已经在tomcat内为web-app设置了一个
JDBCRealm
,当我重新加载它时,我从tomcat得到了它:
SEVERE: A web application registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
I use tomcat 6.0.24, with MySQL Connector 5.1.10,,, 我将tomcat 6.0.24与MySQL Connector 5.1.10配合使用,
Is there a way to clean it up, so tomcat won't display SEVERE
message? 有没有办法清理它,所以tomcat不会显示
SEVERE
消息?
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 ?
如果您有一个singleton对象(JDBC驱动程序),并且在应用程序完成之前永远不会释放它,这有关系吗?
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: 如果确实困扰您,则可以通过重写close方法来解决此问题:
public class XBasicDataSource extends BasicDataSource {
@Override
public synchronized void close() throws SQLException {
DriverManager.deregisterDriver(DriverManager.getDriver(url));
super.close();
}
}
And use your XBasicDataSource . 并使用XBasicDataSource。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.