Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jruby.util;
 
 import java.sql.Driver;
This class gets specially loaded directly in the JRubyClassLoader so that we can unregister all JDBC drivers that were loaded/registered. It gets invoked as part of the Ruby runtime tear down. See http://bugs.jruby.org/4226.
public class JDBCDriverUnloader implements RunnableIterable<Driver> {
    public void run() {
        for (Driver d : this) {
            try {
                DriverManager.deregisterDriver(d);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        }
    }
    public Iterator<Driveriterator() {
        Enumeration<Driverdrivers = DriverManager.getDrivers();
        ArrayList<DriverdriverList = new ArrayList();
        while (drivers.hasMoreElements()) {
            Driver d = drivers.nextElement();
            // JRUBY-5528: Don't unload drivers loaded by parent classloaders.
            if (d.getClass().getClassLoader() == JDBCDriverUnloader.class.getClassLoader()) {
                driverList.add(d);
            }
        }
        return driverList.iterator();
    }
New to GrepCode? Check out our FAQ X