[ 
https://issues.apache.org/jira/browse/DBCP-332?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mark Thomas resolved DBCP-332.
------------------------------

       Resolution: Won't Fix
    Fix Version/s:     (was: 1.4.1)
                       (was: 1.3.1)

I've been thinking about this and there are enough use cases where you don't 
want this to happen - a number of them articulated in this bug report - that I 
think that it makes more sense to leave de-registration of the JDBC driver as a 
client responsibility. It is much easier for the client to de-register the 
driver when it knows it is safe to do so than it is to add a bunch of 
configuration options and other complexity to DBCP.

> Closing BasicDataSource doesn't deregister JDBC driver, causing memory leak
> ---------------------------------------------------------------------------
>
>                 Key: DBCP-332
>                 URL: https://issues.apache.org/jira/browse/DBCP-332
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 1.3, 1.4
>            Reporter: Grzegorz Borkowski
>
> BasicDataSource's method close() doesn't deregister JDBC driver. This causes 
> permgen memory leaks in web server environments, during context reloads. For 
> example, using Tomcat 6.0.26 with Spring, and BasicDataSource declared in 
> Spring context, there is a message printed at web application reload:
> SEVERE: A web application 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.
> I was able to fix it by overriding close method this way:
> {code}
> public class XBasicDataSource extends BasicDataSource {
>     @Override
>     public synchronized void close() throws SQLException {
>         DriverManager.deregisterDriver(DriverManager.getDriver(url));
>         super.close();
>     }
> }
> {code}
> but I think it should be probably the default behavior of BasicDataSource. Or 
> perhaps there should be some flag/setting on BasicDataSource, named 
> "deregisterDriverAtClose" or so.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to