mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve compatible for DBCP
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user