You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2013/05/14 19:00:33 UTC
svn commit: r1482460 - in /commons/proper/dbutils/branches/2_0/src:
changes/changes.xml main/java/org/apache/commons/dbutils2/DbUtils.java
Author: sebb
Date: Tue May 14 17:00:33 2013
New Revision: 1482460
URL: http://svn.apache.org/r1482460
Log:
DBUTILS-106 - DBUtils can't build using JDK 1.7 - DriverProxy needs to implement getParentLogger()
Add dynamic invocation.
Modified:
commons/proper/dbutils/branches/2_0/src/changes/changes.xml
commons/proper/dbutils/branches/2_0/src/main/java/org/apache/commons/dbutils2/DbUtils.java
Modified: commons/proper/dbutils/branches/2_0/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbutils/branches/2_0/src/changes/changes.xml?rev=1482460&r1=1482459&r2=1482460&view=diff
==============================================================================
--- commons/proper/dbutils/branches/2_0/src/changes/changes.xml (original)
+++ commons/proper/dbutils/branches/2_0/src/changes/changes.xml Tue May 14 17:00:33 2013
@@ -48,6 +48,10 @@ The <action> type attribute can be add,u
This is the first release of the 2.x branch of the Commons DbUtils package, DbUtils2.
The motivation for creating DbUtils2 was two-fold: a number of deprecated methods in the original DbUtils, and the desire to support named parameters (DBUTILS-105).
">
+ <action dev="sebb" type="fix" issue="DBUTILS-106">
+ DBUtils can't build using JDK 1.7 - DriverProxy needs to implement getParentLogger()
+ Add dynamic invocation.
+ </action>
<action dev="sebb" type="fix" issue="DBUTILS-109">
AbstractExecutor.currentPosition should be an int
</action>
Modified: commons/proper/dbutils/branches/2_0/src/main/java/org/apache/commons/dbutils2/DbUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/dbutils/branches/2_0/src/main/java/org/apache/commons/dbutils2/DbUtils.java?rev=1482460&r1=1482459&r2=1482460&view=diff
==============================================================================
--- commons/proper/dbutils/branches/2_0/src/main/java/org/apache/commons/dbutils2/DbUtils.java (original)
+++ commons/proper/dbutils/branches/2_0/src/main/java/org/apache/commons/dbutils2/DbUtils.java Tue May 14 17:00:33 2013
@@ -21,6 +21,7 @@ import static java.sql.DriverManager.reg
import java.io.PrintWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverPropertyInfo;
@@ -347,6 +348,8 @@ public final class DbUtils {
*/
private static final class DriverProxy implements Driver {
+ private boolean parentLoggerSupported = true;
+
/**
* The adapted JDBC Driver loaded dynamically.
*/
@@ -395,7 +398,23 @@ public final class DbUtils {
* Java 1.7 method.
*/
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- throw new SQLFeatureNotSupportedException();
+ if (parentLoggerSupported) {
+ try {
+ Method method = adapted.getClass().getMethod("getParentLogger", new Class[0]);
+ return (Logger)method.invoke(adapted, new Object[0]);
+ } catch (NoSuchMethodException e) {
+ parentLoggerSupported = false;
+ throw new SQLFeatureNotSupportedException(e);
+ } catch (IllegalAccessException e) {
+ parentLoggerSupported = false;
+ throw new SQLFeatureNotSupportedException(e);
+ } catch (InvocationTargetException e) {
+ parentLoggerSupported = false;
+ throw new SQLFeatureNotSupportedException(e);
+ }
+ } else {
+ throw new SQLFeatureNotSupportedException();
+ }
}
}