解决方法,新建类并且继承org.apache.commons.dbcp.BasicDataSource类
接着重新close的方法即可。
/** * registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister * Created by alan.luo on 2017/9/5. */ public class BasicDataSourceEx extends BasicDataSource { public BasicDataSourceEx(){ super(); } @Override public synchronized void close() throws SQLException { DriverManager.deregisterDriver(DriverManager.getDriver(url)); super.close(); } }
xml把bean对应的class改成新建的类名就可以了。
<bean id="dataSource" class="com.lanxinbase.system.basic.BasicDataSourceEx" destroy-method="close"> <property name="driverClassName" value="${db.driver}"/> <property name="url" value="${db.url}"></property> <property name="username" value="${db.username}"></property> <property name="password" value="${db.userpasswd}"></property> <property name="initialSize" value="${db.initalsize}"></property> <property name="maxActive" value="${db.maxActive}"></property> <property name="maxIdle" value="${db.maxIdle}"></property> <property name="maxOpenPreparedStatements" value="${db.maxOpens}"></property> <property name="maxWait" value="${db.maxWait}"></property> </bean>
近期评论