Author: sebb
Date: Tue May 14 16:58:14 2013
New Revision: 1482457

URL: http://svn.apache.org/r1482457
Log:
DBUTILS-106 - DBUtils can't build using JDK 1.7 - DriverProxy needs to 
implement getParentLogger()
Add dynamic invocation.

Modified:
    commons/proper/dbutils/trunk/src/changes/changes.xml
    
commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/DbUtils.java

Modified: commons/proper/dbutils/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/dbutils/trunk/src/changes/changes.xml?rev=1482457&r1=1482456&r2=1482457&view=diff
==============================================================================
--- commons/proper/dbutils/trunk/src/changes/changes.xml (original)
+++ commons/proper/dbutils/trunk/src/changes/changes.xml Tue May 14 16:58:14 
2013
@@ -44,6 +44,10 @@ The <action> type attribute can be add,u
   </properties>
   <body>
     <release version="1.6" date="201?-??-??" description="Bugfixes and 
addition of insert methods">
+      <action dev="sebb" due-to="Niall Pemberton" type="fix" 
issue="DBUTILS-106">
+        DBUtils can't build using JDK 1.7 - DriverProxy needs to implement 
getParentLogger()
+        Add dynamic invocation.
+      </action>
       <action dev="wspeirs" due-to="Micah Huff" type="add" issue="DBUTILS-108">
         Create functionality to return auto-generated keys in batches of SQL 
inserts
       </action>

Modified: 
commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/DbUtils.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/DbUtils.java?rev=1482457&r1=1482456&r2=1482457&view=diff
==============================================================================
--- 
commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/DbUtils.java
 (original)
+++ 
commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/DbUtils.java
 Tue May 14 16:58:14 2013
@@ -20,6 +20,8 @@ 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;
@@ -335,6 +337,8 @@ public final class DbUtils {
      */
     private static final class DriverProxy implements Driver {
 
+        private boolean parentLoggerSupported = true;
+
         /**
          * The adapted JDBC Driver loaded dynamically.
          */
@@ -401,7 +405,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();
+            }
         }
 
     }


Reply via email to