From 75eff7f083f4b688d78fd2b4b2b81f48533766dd Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Tue, 11 Feb 2014 09:18:41 -0500 Subject: [PATCH] updated getParentLogger to compile under 1.6 for issue #62 Former-commit-id: 67a48a7f1e48bd922ee772bf7e407c2f8b3ed7e1 --- .../data/nvdcve/DriverShim.java | 73 ++++++++++++------- 1 file changed, 47 insertions(+), 26 deletions(-) diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DriverShim.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DriverShim.java index 8e7b6360b..382b77f4c 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DriverShim.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/data/nvdcve/DriverShim.java @@ -17,12 +17,15 @@ */ package org.owasp.dependencycheck.data.nvdcve; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.sql.Connection; import java.sql.Driver; import java.sql.DriverPropertyInfo; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; +import java.util.logging.Level; import java.util.logging.Logger; /** @@ -64,6 +67,20 @@ class DriverShim implements Driver { return this.driver.acceptsURL(url); } + /** + * Wraps the call to the underlying driver's connect method. + * + * @param url the URL of the database + * @param info a collection of string/value pairs + * @return a Connection object + * @throws SQLException thrown if there is an error connecting to the database + * @see java.sql.Driver#connect(java.lang.String, java.util.Properties) + */ + @Override + public Connection connect(String url, Properties info) throws SQLException { + return this.driver.connect(url, info); + } + /** * Returns the wrapped driver's major version number. * @@ -87,28 +104,33 @@ class DriverShim implements Driver { } /** - * Returns whether or not the wrapped driver is jdbcCompliant. + * Wraps the call to the underlying driver's getParentLogger method. * - * @return true if the wrapped driver is JDBC compliant; otherwise false - * @see java.sql.Driver#jdbcCompliant() + * @return the parent's Logger + * @throws SQLFeatureNotSupportedException thrown if the feature is not supported + * @see java.sql.Driver#getParentLogger() */ - @Override - public boolean jdbcCompliant() { - return this.driver.jdbcCompliant(); - } - - /** - * Wraps the call to the underlying driver's connect method. - * - * @param url the URL of the database - * @param info a collection of string/value pairs - * @return a Connection object - * @throws SQLException thrown if there is an error connecting to the database - * @see java.sql.Driver#connect(java.lang.String, java.util.Properties) - */ - @Override - public Connection connect(String url, Properties info) throws SQLException { - return this.driver.connect(url, info); + //@Override + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + //return driver.getParentLogger(); + Method m = null; + try { + m = driver.getClass().getMethod("getParentLogger"); + } catch (Exception e) { + throw new SQLFeatureNotSupportedException(); + } + if (m != null) { + try { + return (Logger) m.invoke(m); + } catch (IllegalAccessException ex) { + Logger.getLogger(DriverShim.class.getName()).log(Level.FINER, null, ex); + } catch (IllegalArgumentException ex) { + Logger.getLogger(DriverShim.class.getName()).log(Level.FINER, null, ex); + } catch (InvocationTargetException ex) { + Logger.getLogger(DriverShim.class.getName()).log(Level.FINER, null, ex); + } + } + throw new SQLFeatureNotSupportedException(); } /** @@ -126,15 +148,14 @@ class DriverShim implements Driver { } /** - * Wraps the call to the underlying driver's getParentLogger method. + * Returns whether or not the wrapped driver is jdbcCompliant. * - * @return the parent's Logger - * @throws SQLFeatureNotSupportedException thrown if the feature is not supported - * @see java.sql.Driver#getParentLogger() + * @return true if the wrapped driver is JDBC compliant; otherwise false + * @see java.sql.Driver#jdbcCompliant() */ @Override - public Logger getParentLogger() throws SQLFeatureNotSupportedException { - return this.driver.getParentLogger(); + public boolean jdbcCompliant() { + return this.driver.jdbcCompliant(); } /**