You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by aioria3077 <ai...@gmail.com> on 2014/06/25 18:56:34 UTC

Problem with inserting database from camel-context.xml

hi good day, I'm new to all this.

i have the following

<split parallelProcessing="true" streaming="true">
            <tokenize token="\n" group="1"/>
            <unmarshal><csv/></unmarshal>
            <transform>
            <simple>${body[0]}</simple>
            </transform>
            <log message="${body}"/>
            <to uri="sql:INSERT INTO prueba(id, nombre, sex, num)
VALUES(#,#,#,#)"/>
......
......

which works correctly when fields of my database are TEXT, but if I have a
field, for example, ID int, not performing insert, 

any solution within the camel-context.xml or have to resort to a java class
that I do the transformation?




--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-inserting-database-from-camel-context-xml-tp5752810.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with inserting database from camel-context.xml

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

The SQL component does not support providing types in the #
placeholders. You would need to convert the data before. Or you can
take a look at using for example the camel-mybatis component.

Although we could look at improving the sql component so you can
provide the type

Maybe something like

  <to uri="sql:INSERT INTO prueba(id, nombre, sex, num)
VALUES(#int,#,#,#)"/>

Though finding a syntax that works can be a bit tricky.

I logged a ticket about this
https://issues.apache.org/jira/browse/CAMEL-7543





On Wed, Jun 25, 2014 at 6:56 PM, aioria3077 <ai...@gmail.com> wrote:
> hi good day, I'm new to all this.
>
> i have the following
>
> <split parallelProcessing="true" streaming="true">
>             <tokenize token="\n" group="1"/>
>             <unmarshal><csv/></unmarshal>
>             <transform>
>             <simple>${body[0]}</simple>
>             </transform>
>             <log message="${body}"/>
>             <to uri="sql:INSERT INTO prueba(id, nombre, sex, num)
> VALUES(#,#,#,#)"/>
> ......
> ......
>
> which works correctly when fields of my database are TEXT, but if I have a
> field, for example, ID int, not performing insert,
>
> any solution within the camel-context.xml or have to resort to a java class
> that I do the transformation?
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-inserting-database-from-camel-context-xml-tp5752810.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/