You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/12/09 06:12:33 UTC

[camel] branch camel-3.14.x updated: CAMEL-18797: camel-sql - Only fetch parameter count if really needed. Thanks to John Taylor for the patch.

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.14.x by this push:
     new fcf2a783fa9 CAMEL-18797: camel-sql - Only fetch parameter count if really needed. Thanks to John Taylor for the patch.
fcf2a783fa9 is described below

commit fcf2a783fa9bb61a59cfd763d6b1790692ebc006
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Dec 9 07:11:16 2022 +0100

    CAMEL-18797: camel-sql - Only fetch parameter count if really needed. Thanks to John Taylor for the patch.
---
 .../src/main/java/org/apache/camel/component/sql/SqlProducer.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
index bf8e9bcfcbb..369f05d9f7c 100644
--- a/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
+++ b/components/camel-sql/src/main/java/org/apache/camel/component/sql/SqlProducer.java
@@ -250,8 +250,12 @@ public class SqlProducer extends DefaultProducer {
 
     private void populateStatement(PreparedStatement ps, Exchange exchange, String sql, String preparedQuery)
             throws SQLException {
-        int psParametersCount = ps.getParameterMetaData() != null ? ps.getParameterMetaData().getParameterCount() : 0;
-        int expected = parametersCount > 0 ? parametersCount : psParametersCount;
+        int expected;
+        if (parametersCount > 0) {
+            expected = parametersCount;
+        } else {
+            expected = ps.getParameterMetaData() != null ? ps.getParameterMetaData().getParameterCount() : 0;
+        }
 
         // only populate if really needed
         if (alwaysPopulateStatement || expected > 0) {