应用程序注册了JDBC驱动,但当程序停止时无法注销这个驱动,tomcat为了防止内存溢出,就给强制注销了

 

解决:

重写了org.apache.commons.dbcp.BasicDataSource  的 close()方法:

 

package org.company.util;

import 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{
//  System.out.println("......输出数据源Driver的url:"+DriverManager.getDriver(url));
  DriverManager.deregisterDriver(DriverManager.getDriver(url));
  super.close();
 }
}

。。。

 

在dbcp数据源中的配置:

  class="org.company.util.XBasicDataSource" destroy-method="close">
  
   value="oracle.jdbc.driver.OracleDriver">
  
  
   value="jdbc:oracle:thin:@XX.XXX.XX.X:1521:ccdb">
  

 

问题解决~

-------------------------------------------------------------------------------------------------------------

再重新加载的时候发现还有:

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

2012-2-9 17:43:12 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

检查了一下jar包  发现多了一个mysql-connector-java-bin.jar   赶紧删之   ok~