updated getParentLogger to compile under 1.6 for issue #62

Former-commit-id: 67a48a7f1e48bd922ee772bf7e407c2f8b3ed7e1
This commit is contained in:
Jeremy Long
2014-02-11 09:18:41 -05:00
parent f9f4be181d
commit 75eff7f083

View File

@@ -17,12 +17,15 @@
*/ */
package org.owasp.dependencycheck.data.nvdcve; package org.owasp.dependencycheck.data.nvdcve;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.Connection; import java.sql.Connection;
import java.sql.Driver; import java.sql.Driver;
import java.sql.DriverPropertyInfo; import java.sql.DriverPropertyInfo;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException; import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
@@ -64,6 +67,20 @@ class DriverShim implements Driver {
return this.driver.acceptsURL(url); 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. * 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 * @return the parent's Logger
* @see java.sql.Driver#jdbcCompliant() * @throws SQLFeatureNotSupportedException thrown if the feature is not supported
* @see java.sql.Driver#getParentLogger()
*/ */
@Override //@Override
public boolean jdbcCompliant() { public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return this.driver.jdbcCompliant(); //return driver.getParentLogger();
Method m = null;
try {
m = driver.getClass().getMethod("getParentLogger");
} catch (Exception e) {
throw new SQLFeatureNotSupportedException();
} }
if (m != null) {
/** try {
* Wraps the call to the underlying driver's connect method. return (Logger) m.invoke(m);
* } catch (IllegalAccessException ex) {
* @param url the URL of the database Logger.getLogger(DriverShim.class.getName()).log(Level.FINER, null, ex);
* @param info a collection of string/value pairs } catch (IllegalArgumentException ex) {
* @return a Connection object Logger.getLogger(DriverShim.class.getName()).log(Level.FINER, null, ex);
* @throws SQLException thrown if there is an error connecting to the database } catch (InvocationTargetException ex) {
* @see java.sql.Driver#connect(java.lang.String, java.util.Properties) Logger.getLogger(DriverShim.class.getName()).log(Level.FINER, null, ex);
*/ }
@Override }
public Connection connect(String url, Properties info) throws SQLException { throw new SQLFeatureNotSupportedException();
return this.driver.connect(url, info);
} }
/** /**
@@ -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 * @return true if the wrapped driver is JDBC compliant; otherwise false
* @throws SQLFeatureNotSupportedException thrown if the feature is not supported * @see java.sql.Driver#jdbcCompliant()
* @see java.sql.Driver#getParentLogger()
*/ */
@Override @Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException { public boolean jdbcCompliant() {
return this.driver.getParentLogger(); return this.driver.jdbcCompliant();
} }
/** /**