registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it

寒假时在家看视频学习ssh,第一次将它们整合在一起,就出了问题:

 

严重: The web application [/] registered the JDBC 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.

2012-2-15 15:25:22 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

严重: The web application [/] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.

 

 

我用的是strut2.2.3+hibernate3+spring2.5.6+tomcat7.0.22+mysql5

 

看tomcat的启动信息是,应用程序注册了jdbc驱动,但是结束时无法注销,tomcat于是为防止内存泄露,强制注销了,

网上说是DBCP的bug

 

于是按https://issues.apache.org/jira/browse/DBCP-332上讲的

 

另外写一个类,继承org.apache.commons.dbcp.BasicDataSource来注销jdbcimport java.sql.DriverManager;

import java.sql.SQLException;

import org.apache.commons.dbcp.BasicDataSource;

public class XBasicDataSource extends BasicDataSource 
{
    @Override
    public synchronized void close() throws SQLException {
        DriverManager.deregisterDriver(DriverManager.getDriver(url));
        super.close();
    }
}

 于是问题终于解决了!不知还有没更好的方法?

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值