bug fixed for load driverClass

This commit is contained in:
wenshao
2012-07-18 21:36:42 +08:00
parent 91ff69cdce
commit 5c01638bc1
@@ -488,12 +488,23 @@ public final class JdbcUtils {
}
public static Driver createDriver(String driverClassName) throws SQLException {
ClassNotFoundException exception = null;
try {
return (Driver) Class.forName(driverClassName).newInstance();
} catch (IllegalAccessException e) {
throw new SQLException(e.getMessage(), e);
} catch (InstantiationException e) {
throw new SQLException(e.getMessage(), e);
} catch (ClassNotFoundException e) {
exception = e;
}
try {
return (Driver) Thread.currentThread().getContextClassLoader().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);
}