improve compatible for DBCP

This commit is contained in:
wenshao
2012-10-20 05:08:04 +08:00
parent 3c04c2d06b
commit 26e3fa3987
5 changed files with 53 additions and 4 deletions
@@ -497,8 +497,24 @@ public final class JdbcUtils {
return null;
}
}
public static Driver createDriver(String driverClassName) throws SQLException {
return createDriver(null, driverClassName);
}
public static Driver createDriver(ClassLoader classLoader, String driverClassName) throws SQLException {
if (classLoader != null) {
try {
return (Driver) classLoader.loadClass(driverClassName).newInstance();
} catch (IllegalAccessException e) {
throw new SQLException(e.getMessage(), e);
} catch (InstantiationException e) {
throw new SQLException(e.getMessage(), e);
} catch (ClassNotFoundException e) {
throw new SQLException(e.getMessage(), e);
}
}
try {
return (Driver) Class.forName(driverClassName).newInstance();
} catch (IllegalAccessException e) {