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 8FEA99BD9 for ; Wed, 16 Nov 2011 13:37:42 +0000 (UTC) Received: (qmail 80712 invoked by uid 500); 16 Nov 2011 13:37:42 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 80680 invoked by uid 500); 16 Nov 2011 13:37:42 -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 80672 invoked by uid 99); 16 Nov 2011 13:37:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Nov 2011 13:37:42 +0000 X-ASF-Spam-Status: No, hits=1.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of raul@fusesource.com designates 74.125.245.88 as permitted sender) Received: from [74.125.245.88] (HELO na3sys010aog110.obsmtp.com) (74.125.245.88) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Nov 2011 13:37:36 +0000 Received: from mail-fx0-f45.google.com ([209.85.161.45]) (using TLSv1) by na3sys010aob110.postini.com ([74.125.244.12]) with SMTP ID DSNKTsO8i+q+DpgYri9jzLFOqRM4XgnnEd2t@postini.com; Wed, 16 Nov 2011 05:37:16 PST Received: by mail-fx0-f45.google.com with SMTP id s14so1824203faa.32 for ; Wed, 16 Nov 2011 05:37:15 -0800 (PST) Received: by 10.182.12.69 with SMTP id w5mr7050331obb.31.1321450635160; Wed, 16 Nov 2011 05:37:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.35.170 with HTTP; Wed, 16 Nov 2011 05:36:54 -0800 (PST) In-Reply-To: <1321425175373-4996795.post@n5.nabble.com> References: <1321362774466-4994243.post@n5.nabble.com> <1321362800225-4994244.post@n5.nabble.com> <1321366989183-4994400.post@n5.nabble.com> <1321425175373-4996795.post@n5.nabble.com> From: Raul Kripalani Date: Wed, 16 Nov 2011 13:36:54 +0000 Message-ID: Subject: Re: How can I update database table by using camel routing? To: users@camel.apache.org Content-Type: multipart/alternative; boundary=f46d044469b7b26abf04b1da331d --f46d044469b7b26abf04b1da331d Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi folcadi, As a side note, our peer Charles Moulliard presented a webinar a few weeks ago that digs deep into Persistence with Camel, comparing the wide range of options that Camel offers you to achieve this: camel-jdbc, camel-sql, camel-jpa, etc. You can watch the webinar [1] to understand the trade-offs of going one way or another for your use case. The examples are also downloadable from the same site. Additionally, Part II next week will delve into transactions (standalone and XA), which may be of interest to you. [1] http://fusesource.com/resources/video-archived-webinars/. -- Ra=FAl. On 16 November 2011 06:32, focaldi wrote: > Thanks for your advice Christian, another thanks for Claus :)... I change= d > my > code like below and it works fine. Now, I wanna ask another question : > Which > one is the best solution in your opinion? > > public class RouteDatabaseToJms extends RouteBuilder { > @Override > public void configure() throws Exception { > > DataSource ds =3D this.getContext().getRegistry().lookup("dataSour= ce", > DataSource.class); > this.getContext().getComponent("sql", > SqlComponent.class).setDataSource(ds); > > > //final JdbcTemplate jdbc =3D new JdbcTemplate(ds); > > final ProducerTemplate template =3D > this.getContext().createProducerTemplate(); > > from("timer://foo?period=3D60000").setBody(constant("select * from > AIRPORT")).to("jdbc:dataSource"). > process(new Processor(){ > @Override > public void process(Exchange exchange) throws > Exception { > ArrayList> data= =3D > exchange.getIn().getBody(ArrayList.class); > for (HashMap item : data){ > > System.out.println("DATABASE:::item.IATA_CODE > :"+((String)item.get("IATA_CODE"))); > } > } > }).to("jms:queue:airport"); > > from("jms:queue:airport").process(new Processor(){ > > @Override > public void process(Exchange exchange) throws > Exception { > > ArrayList> data= =3D > exchange.getIn().getBody(ArrayList.class); > for (HashMap item : data){ > > template.sendBody("direct:update",(BigDecimal)item.get("ID")); > //jdbc.update("update airport set > description_tr=3D'tamam1' where > id=3D?",new Object[]{(BigDecimal)item.get("ID")}); > > System.out.println("JMS:::item.IATA_CODE > :"+((String)item.get("IATA_CODE"))); > } > } > > }); > > from("direct:update").to("sql:update airport set > description_tr=3D'okkk' > where id=3D#"); > > } > > } > > -- > View this message in context: > http://camel.465427.n5.nabble.com/How-can-I-update-database-table-by-usin= g-camel-routing-tp4994243p4996795.html > Sent from the Camel - Users mailing list archive at Nabble.com. > --f46d044469b7b26abf04b1da331d--