Only unload JDBC drivers this web app loaded.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 21 Dec 2009 17:15:41 +0000 (17:15 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 21 Dec 2009 17:15:41 +0000 (17:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@892887 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/loader/JdbcLeakPrevention.java

index 1aa1034..6f10dc8 100644 (file)
@@ -38,23 +38,16 @@ import java.util.List;
  */
 public class JdbcLeakPrevention {
 
-    /* 
-     * This driver is visible to all classloaders but is loaded by the system
-     * class loader so there is no need to unload it.
-     */
-    private static final String JDBC_ODBC_BRIDGE_DRIVER =
-        "sun.jdbc.odbc.JdbcOdbcDriver";
-    
     public List<String> clearJdbcDriverRegistrations() throws SQLException {
         List<String> driverNames = new ArrayList<String>();
-        
-        // Unregister any JDBC drivers loaded by the class loader that loaded
-        // this class - ie the webapp class loader
+
+        // This will list all drivers visible to this class loader
         Enumeration<Driver> drivers = DriverManager.getDrivers();
         while (drivers.hasMoreElements()) {
             Driver driver = drivers.nextElement();
-            if (JDBC_ODBC_BRIDGE_DRIVER.equals(
-                    driver.getClass().getCanonicalName())) {
+            // Only unload the drivers this web app loaded
+            if (driver.getClass().getClassLoader() !=
+                this.getClass().getClassLoader()) {
                 continue;
             }
             driverNames.add(driver.getClass().getCanonicalName());