diff --git a/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/JDBCDriverManager.java b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/JDBCDriverManager.java index f826d2091c..b6ba12e916 100644 --- a/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/JDBCDriverManager.java +++ b/data/org.eclipse.birt.report.data.oda.jdbc/src/org/eclipse/birt/report/data/oda/jdbc/JDBCDriverManager.java @@ -27,6 +27,7 @@ import java.sql.DriverPropertyInfo; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -282,6 +283,7 @@ private Connection doConnect(String driverClass, String url, String jndiNameUrl, try { Driver driver = DriverManager.getDriver(url); if (driver != null) { + removeUnsupportedConnectionProperties(driver, url, connectionProperties); return driver.connect(url, connectionProperties); } } catch (SQLException e1) { @@ -292,6 +294,7 @@ private Connection doConnect(String driverClass, String url, String jndiNameUrl, } try { + removeUnsupportedConnectionProperties(DriverManager.getDriver(url), url, connectionProperties); return DriverManager.getConnection(url, connectionProperties); } catch (SQLException e) { try { @@ -301,7 +304,9 @@ private Connection doConnect(String driverClass, String url, String jndiNameUrl, Class dc = dl.loadClass(driverClass); if (dc != null) { - Connection conn = ((Driver) dc.newInstance()).connect(url, connectionProperties); + Driver driver = (Driver) dc.newInstance(); + removeUnsupportedConnectionProperties(driver, url, connectionProperties); + Connection conn = driver.connect(url, connectionProperties); if (conn != null) { return conn; } @@ -313,6 +318,36 @@ private Connection doConnect(String driverClass, String url, String jndiNameUrl, } } + /* + * Remove unsupported properties from the connection properties + * based on the driver property information set + */ + private void removeUnsupportedConnectionProperties(Driver driver, String url, Properties connectionProperties) { + try { + DriverPropertyInfo[] supportedProperties = driver.getPropertyInfo(url, connectionProperties); + if (supportedProperties != null && connectionProperties != null) { + ArrayList unsupportedDriverProperties = new ArrayList(); + connectionProperties.forEach((key, value) -> { + boolean isPropertySupported = false; + for (DriverPropertyInfo supportedProperty : supportedProperties) { + if (supportedProperty.name.equalsIgnoreCase(key.toString())) { + isPropertySupported = true; + break; + } + } + // registry of unsupported connection properties + if (!isPropertySupported) + unsupportedDriverProperties.add(key.toString()); + }); + + // remove unsupported connection properties + for (String unsupportedProperty : unsupportedDriverProperties) + connectionProperties.remove(unsupportedProperty); + } + } catch (SQLException e) { + // do nothing, standard handling + } + } /** * * @param message