title: Loading JDBC Driver at Runtime
body: <p>I'm using the following code to load a driver class:</p>
  
  <pre><code>public class DriverLoader extends URLClassLoader {
  
      private DriverLoader(URL[] urls) {
          super(urls);
          File driverFolder = new File("driver");
          File[] files = driverFolder.listFiles();
          for (File file : files) {
              try {
                  addURL(file.toURI().toURL());
              } catch (MalformedURLException e) {
              }
          }
      }
  
  
      private static DriverLoader driverLoader;
  
  
      public static void load(String driverClassName) throws ClassNotFoundException {
          try {
              Class.forName(driverClassName);
          } catch (ClassNotFoundException ex) {
              if (driverLoader == null) {
                  URL urls[] = {};
                  driverLoader = new DriverLoader(urls);
              }
              driverLoader.loadClass(driverClassName);
          }
      }
  }
  </code></pre>
  
  <p>Although the class loads fine I can't establish a Database connection (No suitable driver found for ...) no matter which driver I try.</p>
  
  <p>I assume this is because I'm not loading the driver class using Class.forName (which wouldn't work since I'm using my own ClassLoader). How can I fix this?</p>