[url]http://stackoverflow.com/questions/11872316/tomcat-guice-jdbc-memory-leak[/url]
[color=red]jdbc.dataSource=com.pandy.core.ds.XBasicDataSource[/color]
public class XBasicDataSource extends DruidDataSource {
@Override
public void close(){
Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
try {
DriverManager.deregisterDriver(driver);
} catch (SQLException e) {
e.printStackTrace();
}
}
try {
AbandonedConnectionCleanupThread.shutdown();
} catch (InterruptedException e) {
//logger.warn("SEVERE problem cleaning up: " + e.getMessage());
e.printStackTrace();
}
super.close();
}
}[color=red]jdbc.dataSource=com.pandy.core.ds.XBasicDataSource[/color]

本文讨论了在Tomcat环境下使用XBasicDataSource作为数据源时引发的JDBC内存泄漏问题,并提供了有效的解决方法。
1114

被折叠的 条评论
为什么被折叠?



