Return-Path: X-Original-To: apmail-camel-issues-archive@minotaur.apache.org Delivered-To: apmail-camel-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5EFB91731D for ; Tue, 11 Nov 2014 01:30:34 +0000 (UTC) Received: (qmail 43024 invoked by uid 500); 11 Nov 2014 01:30:34 -0000 Delivered-To: apmail-camel-issues-archive@camel.apache.org Received: (qmail 42982 invoked by uid 500); 11 Nov 2014 01:30:34 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 42965 invoked by uid 99); 11 Nov 2014 01:30:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Nov 2014 01:30:34 +0000 Date: Tue, 11 Nov 2014 01:30:33 +0000 (UTC) From: "Willem Jiang (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CAMEL-7803) DefaultJdbcPrepareStatementStrategy Iterator fails on null value inserts MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-7803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14205758#comment-14205758 ] Willem Jiang edited comment on CAMEL-7803 at 11/11/14 1:29 AM: --------------------------------------------------------------- As we target Camel 2.14.1 release at the end of this year, I suggest you to use the Camel 2.13.3 if you are not using any new Camel components of 2.14.0. was (Author: njiang): As we are target Camel 2.14.1 release to the end of this year, I suggest you to use the Camel 2.13.3 if you are not using any new Camel components of 2.14.0. > DefaultJdbcPrepareStatementStrategy Iterator fails on null value inserts > ------------------------------------------------------------------------ > > Key: CAMEL-7803 > URL: https://issues.apache.org/jira/browse/CAMEL-7803 > Project: Camel > Issue Type: Bug > Components: camel-jdbc > Affects Versions: 2.13.2 > Reporter: Nathan Wray > Assignee: Willem Jiang > Fix For: 2.12.5, 2.13.3, 2.14.1, 2.15.0 > > Attachments: 7803-patch.txt > > > The iterator returned by createPopulateIterator in DefaultJdbcPrepareStatementStrategy incorrectly uses a next value of "null" to identify when it has run out of parameters. This fails when the parameter map intentionally contains a name with a null value, which is the case when some columns in an insert should be set to null. The attached pull request adds an explicit preFetch flag and relies on the done flag, avoiding the incorrect overloading of (next==null) to indicate completion. > The iterator reports "hasNext() == false" when it encounters a map value of null. This happens when using the map header JDBC_PARAMETERS = "CamelJdbcParameters" to insert null values with a prepared statement. The Iterator ends prematurely when it reaches a parameter name with a null value. > For example, passing in a map where the 3rd parameter of 19 has a value of null causes the following exception to be thrown: > java.sql.SQLException: Number of parameters mismatch. Expected: 19, was:2 > at org.apache.camel.component.jdbc.DefaultJdbcPrepareStatementStrategy.populateStatement(DefaultJdbcPrepareStatementStrategy.java:137) > at org.apache.camel.component.jdbc.JdbcProducer.doCreateAndExecuteSqlStatementWithHeaders(JdbcProducer.java:133) > at org.apache.camel.component.jdbc.JdbcProducer.createAndExecuteSqlStatement(JdbcProducer.java:116) > at org.apache.camel.component.jdbc.JdbcProducer.processingSqlBySettingAutoCommit(JdbcProducer.java:85) -- This message was sent by Atlassian JIRA (v6.3.4#6332)