Here you can find the source of getDriverFromPath(String path, String className)
public static Driver getDriverFromPath(String path, String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, MalformedURLException
//package com.java2s; /******************************************************************************* * Copyright (c) 2006 Bruno G. Braga./*from w w w .j av a 2 s .com*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Bruno G. Braga - initial API and implementation *******************************************************************************/ import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.sql.Driver; public class Main { public static Driver getDriverFromPath(String path, String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException, MalformedURLException { URL[] url = { new File(path).toURL() }; URLClassLoader loader = new URLClassLoader(url); Class c = loader.loadClass(className); Object instance = c.newInstance(); return (Driver) instance; } }