天天看點

This is very likely to create a memory leak

[url]http://stackoverflow.com/questions/11872316/tomcat-guice-jdbc-memory-leak[/url]

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]