commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thecarlh...@apache.org
Subject [28/50] commons-dbutils git commit: DBUTILS-117 Error handling possible getParameterMetaData() results
Date Fri, 07 Jul 2017 02:06:03 GMT
DBUTILS-117 Error handling possible getParameterMetaData() results

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/trunk@1645683 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/85a7a2b2
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/85a7a2b2
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/85a7a2b2

Branch: refs/heads/master
Commit: 85a7a2b27cd5d2a1a69ae2746bdaf32f7f021b07
Parents: 8456914
Author: Sebastian Bazley <sebb@apache.org>
Authored: Mon Dec 15 16:13:07 2014 +0000
Committer: Sebastian Bazley <sebb@apache.org>
Committed: Mon Dec 15 16:13:07 2014 +0000

----------------------------------------------------------------------
 src/changes/changes.xml                             |  4 ++++
 .../apache/commons/dbutils/AbstractQueryRunner.java | 16 ++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/85a7a2b2/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 7cf1faf..a7c1792 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -45,6 +45,10 @@ The <action> type attribute can be add,update,fix,remove.
   <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>

http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/85a7a2b2/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
index 7319496..dcf2cef 100644
--- a/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
+++ b/src/main/java/org/apache/commons/dbutils/AbstractQueryRunner.java
@@ -223,12 +223,16 @@ public abstract class AbstractQueryRunner {
         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