Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0458718B63 for ; Sun, 27 Dec 2015 21:41:21 +0000 (UTC) Received: (qmail 89762 invoked by uid 500); 27 Dec 2015 21:41:20 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 89721 invoked by uid 500); 27 Dec 2015 21:41:20 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 89709 invoked by uid 99); 27 Dec 2015 21:41:20 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Dec 2015 21:41:20 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 902BDC07DB for ; Sun, 27 Dec 2015 21:41:19 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.193 X-Spam-Level: **** X-Spam-Status: No, score=4.193 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id WgQyFeCnefpq for ; Sun, 27 Dec 2015 21:41:12 +0000 (UTC) Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com [209.85.215.42]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 4FEC3439AD for ; Sun, 27 Dec 2015 21:41:12 +0000 (UTC) Received: by mail-lf0-f42.google.com with SMTP id z124so185680748lfa.3 for ; Sun, 27 Dec 2015 13:41:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=2vZ9XNr4Bpa7SWHCDVgkVwcozkAhGOzqFRiBQ5r4aiA=; b=vPiVcoVT5Ji1rwHgNzmGDbd0egRfMAeCIlFWmKNR9W7s1sq8YKmjp7pHEV6CgB7Fk2 HKZ4c/LWfSHh2WiMiB9LKsrVFmx2TwQuEHlvg/cfCslhclG3/XcBBysYemS7m06X0UNB ZA0rP7rEseRpX8+Kd8/w/V+MWOApi3bU6DlsnrwAyZF+hWpFxnMXK2WwYvh/hG2Q8LBb qcuDWZ6R7st50ZVaOZEMelcrs56BwIdnszpNEks1ngBJN8qp+uV8D+amcFYmh2KH1/Kf tEUomqTxhnMZnCvBelAXmK0lNT1ihNUIPiiimWa9E4mJJN2+RFhYYmAcqm879kWJElim RXQA== X-Received: by 10.25.18.231 with SMTP id 100mr17980228lfs.25.1451252464978; Sun, 27 Dec 2015 13:41:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.41.212 with HTTP; Sun, 27 Dec 2015 13:40:45 -0800 (PST) In-Reply-To: <1450860845032-5775389.post@n5.nabble.com> References: <1450860611333-5775388.post@n5.nabble.com> <1450860845032-5775389.post@n5.nabble.com> From: Alessandro Rontani Date: Sun, 27 Dec 2015 22:40:45 +0100 Message-ID: Subject: Re: Unable to resolve named parameter in camel route To: users@camel.apache.org Content-Type: multipart/alternative; boundary=001a113f67eea792510527e80b2d --001a113f67eea792510527e80b2d Content-Type: text/plain; charset=UTF-8 Your problem is that the parameters *numbersubscribers* and and *id* must be present as headers in the message: when your message reach the jdbc component the body of the message contains the query, but cannot find the parameters. Doing something like this can solve your problem: from("timer://foo?period="+serverData.getTimer()) .threads(serverData.getNumberOfInstances()) .setBody(constant(serverData.getSql())).to("jdbc:"+ serverData.getUrl() + serverData.getUserId()) *.setHeader("id",simple("${body[0][id]}"))* *.setHeader("numbersubscribers",simple("${body[0][numbersubscribers]}"))* .setBody(constant("insert into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers,:?id)")) .to("jdbc:" + serverData.getUrl() + serverData.getUserId()+"?allowNamedParameters=true&outputType=SelectOne&useHeadersAsParameters=true&resetAutoCommit=false") .process(custom application logic); your first query on JDBC component returns a list (representing the db rows returned), and every element of the list is a map with the column name as key and the value in the row as value. The code in bold above put into the headers the values retrieved from the body. The solution suggested works if the first DB call returns at least a row, if there is no result probably it will raise an ArrayOutOfBound exception I hope that the syntax that i have used is correct (i use always the XML notation, not the Java one ^_^ ) Best Regards Alessandro Rontani -- *Siamo quello che facciamo ripetutamente. L'eccellenza non e' un atto, ma abitudine - *Aristotele 2015-12-23 9:54 GMT+01:00 ghoshp29 : > One typo in the camel route syntax. Correct syntax used in application is > below - > > > from("timer://foo?period="+serverData.getTimer()).threads(serverData.getNumberOfInstances()).setBody(constant(serverData.getSql())).to("jdbc:" > + serverData.getUrl() + serverData.getUserId()).setBody(constant("insert > into new_raw_table_test (numbersubscribers, id) values(:?numbersubscribers, > :?id)")). > to("jdbc:" + serverData.getUrl() + > > serverData.getUserId()+"?allowNamedParameters=true&outputType=SelectOne&useHeadersAsParameters=true&resetAutoCommit=false").process(custom > application logic); > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Unable-to-resolve-named-parameter-in-camel-route-tp5775388p5775389.html > Sent from the Camel - Users mailing list archive at Nabble.com. > --001a113f67eea792510527e80b2d--