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:06 UTC
[camel] branch camel-3.18.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.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.18.x by this push:
new 0dfd1a88ff0 CAMEL-18797: camel-sql - Only fetch parameter count if really needed. Thanks to John Taylor for the patch.
0dfd1a88ff0 is described below
commit 0dfd1a88ff0b974b12b11618db12be6eacaef38e
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 c0c606416e8..4f8856fd2d8 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
@@ -245,8 +245,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) {