commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1645716 - in /commons/proper/dbutils/trunk/src: changes/changes.xml main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
Date Mon, 15 Dec 2014 18:38:42 GMT
Author: sebb
Date: Mon Dec 15 18:38:41 2014
New Revision: 1645716

URL: http://svn.apache.org/r1645716
Log:
DBUTILS-117 Error handling possible getParameterMetaData() results
- handle SQLFeatureNotSupportedException

Modified:
    commons/proper/dbutils/trunk/src/changes/changes.xml
    commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.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=1645716&r1=1645715&r2=1645716&view=diff
==============================================================================
--- commons/proper/dbutils/trunk/src/changes/changes.xml (original)
+++ commons/proper/dbutils/trunk/src/changes/changes.xml Mon Dec 15 18:38:41 2014
@@ -48,6 +48,7 @@ The <action> type attribute can be add,u
       <action dev="sebb" type="update" issue="DBUTILS-117" due-to="Vadim Smirnov">
         Error handling possible getParameterMetaData() results
         - allow for null return
+        - handle SQLFeatureNotSupportedException
       </action>
       <action dev="britter" type="update" issue="DBUTILS-119" due-to="Michael Akerman">
         Correct errors in BeanMapHandler JavaDoc

Modified: commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
URL: http://svn.apache.org/viewvc/commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java?rev=1645716&r1=1645715&r2=1645716&view=diff
==============================================================================
--- commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
(original)
+++ commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
Mon Dec 15 18:38:41 2014
@@ -26,6 +26,7 @@ import java.sql.ParameterMetaData;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
 import java.sql.Statement;
 import java.sql.Types;
 import java.util.Arrays;
@@ -222,18 +223,23 @@ public abstract class AbstractQueryRunne
         // check the parameter count, if we can
         ParameterMetaData pmd = null;
         if (!pmdKnownBroken) {
-            pmd = stmt.getParameterMetaData();
-            if (pmd == null) { // can be returned by implementations that don't support the
method
-                pmdKnownBroken = true;
-            } else {
-                int stmtCount = pmd.getParameterCount();
-                int paramsCount = params == null ? 0 : params.length;
-    
-                if (stmtCount != paramsCount) {
-                    throw new SQLException("Wrong number of parameters: expected "
-                            + stmtCount + ", was given " + paramsCount);
+            try {
+                pmd = stmt.getParameterMetaData();
+                if (pmd == null) { // can be returned by implementations that don't support
the method
+                    pmdKnownBroken = true;
+                } else {
+                    int stmtCount = pmd.getParameterCount();
+                    int paramsCount = params == null ? 0 : params.length;
+        
+                    if (stmtCount != paramsCount) {
+                        throw new SQLException("Wrong number of parameters: expected "
+                                + stmtCount + ", was given " + paramsCount);
+                    }
                 }
+            } catch (SQLFeatureNotSupportedException ex) {
+                pmdKnownBroken = true;                
             }
+            // TODO see DBUTILS-117: would it make sense to catch any other SQLEx types here?
         }
 
         // nothing to do here
@@ -250,6 +256,7 @@ public abstract class AbstractQueryRunne
                 // OTHER don't work with Oracle's drivers.
                 int sqlType = Types.VARCHAR;
                 if (!pmdKnownBroken) {
+                    // TODO see DBUTILS-117: does it make sense to catch SQLEx here?
                     try {
                         /*
                          * It's not possible for pmdKnownBroken to change from



Mime
View raw message