commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1645683 - in /commons/proper/dbutils/trunk/src: changes/changes.xml main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
Date Mon, 15 Dec 2014 16:13:08 GMT
Author: sebb
Date: Mon Dec 15 16:13:07 2014
New Revision: 1645683

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

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=1645683&r1=1645682&r2=1645683&view=diff
==============================================================================
--- commons/proper/dbutils/trunk/src/changes/changes.xml (original)
+++ commons/proper/dbutils/trunk/src/changes/changes.xml Mon Dec 15 16:13:07 2014
@@ -45,6 +45,10 @@ The <action> type attribute can be add,u
   <body>
 
     <release version="1.7" date="TBA" description="TBD">
+      <action dev="sebb" type="update" issue="DBUTILS-117" due-to="Vadim Smirnov">
+        Error handling possible getParameterMetaData() results
+        - allow for null return
+      </action>
       <action dev="britter" type="update" issue="DBUTILS-117" due-to="Michael Akerman">
         Correct errors in BeanMapHandler JavaDoc
       </action>

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=1645683&r1=1645682&r2=1645683&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 16:13:07 2014
@@ -223,12 +223,16 @@ public abstract class AbstractQueryRunne
         ParameterMetaData pmd = null;
         if (!pmdKnownBroken) {
             pmd = stmt.getParameterMetaData();
-            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);
+            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);
+                }
             }
         }
 



Mime
View raw message