Unverified 提交 3b94a13e authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #696 from igor-suhorukov/master

fix postgres connection issue #695 with redshift driver in classpath
......@@ -11,11 +11,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectStreamClass;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Properties;
......@@ -294,7 +290,13 @@ public class JdbcUtils {
} else {
Class<?> d = loadUserClass(driver);
if (java.sql.Driver.class.isAssignableFrom(d)) {
return DriverManager.getConnection(url, prop);
try {
Driver driverInstance = (Driver) d.newInstance();
return driverInstance.connect(url, prop); /*fix issue #695 with drivers with the same
jdbc subprotocol in classpath of jdbc drivers (as example redshift and postgresql drivers)*/
} catch (Exception e) {
throw DbException.toSQLException(e);
}
} else if (javax.naming.Context.class.isAssignableFrom(d)) {
// JNDI context
try {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论