<camel:route id="Csv to DB example"
autoStartup="true">
<camel:from uri="file:input/csv?noop=true橪;delay=10" />
<camel:split parallelProcessing="true" streaming="true">
<camel:tokenize token="\n" group="1" />
<camel:unmarshal>
<camel:csv />
</camel:unmarshal>
<transform>
<simple>${body[0]}</simple>
</transform>
<camel:to
uri="sql:insert into palyer (id, name, city) values
(#,#,#)?dataSourceRef=dataSource" />
</camel:split>
<camel:stop />
</camel:route>
When I try with following code
public void configure() throws Exception {
logger.info("CSV file to Database");
from("file:input/inbox?noop=true").
unmarshal().csv().transform().body().
to("sql:insert into palyer (id, name, city) values
(#,#,#)?dataSourceRef=dataSource").
stop();
I got this error
thread #0 - file://input/inbox] GenericFileOnCompletion WARN
Rollback file strategy:
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy [ at ] 1f707a6a
for file: GenericFile[data.txt]
[thread #0 - file://input/inbox] DefaultErrorHandler ERROR Failed
delivery for (MessageId: ID- PC-56648-1393004785733-0-69 on ExchangeId:
ID-vgsc-PC-56648-1393004785733-0-70). Exhausted after delivery attempt: 1
caught: org.springframework.jdbc.UncategorizedSQLException:
PreparedStatementCallback; uncategorized SQLException for SQL [insert into
palyer (id, name, city) values (?,?,?)]; SQL state [null]; error code [0];
Number of parameters mismatch. Expected: 3, was:2; nested exception is
java.sql.SQLException: Number of parameters mismatch. Expected: 3, was:2
org.springframework.jdbc.UncategorizedSQLException:
PreparedStatementCallback; uncategorized SQLException for SQL [insert into
palyer (id, name, city) values (?,?,?)];
SQL state [null]; error code [0]; Number of parameters mismatch. Expected:
3, was:2;
nested exception is java.sql.SQLException: Number of parameters mismatch.
Expected: 3, was:2
autoStartup="true">
<camel:from uri="file:input/csv?noop=true橪;delay=10" />
<camel:split parallelProcessing="true" streaming="true">
<camel:tokenize token="\n" group="1" />
<camel:unmarshal>
<camel:csv />
</camel:unmarshal>
<transform>
<simple>${body[0]}</simple>
</transform>
<camel:to
uri="sql:insert into palyer (id, name, city) values
(#,#,#)?dataSourceRef=dataSource" />
</camel:split>
<camel:stop />
</camel:route>
When I try with following code
public void configure() throws Exception {
logger.info("CSV file to Database");
from("file:input/inbox?noop=true").
unmarshal().csv().transform().body().
to("sql:insert into palyer (id, name, city) values
(#,#,#)?dataSourceRef=dataSource").
stop();
I got this error
thread #0 - file://input/inbox] GenericFileOnCompletion WARN
Rollback file strategy:
org.apache.camel.component.file.strategy.GenericFileRenameProcessStrategy [ at ] 1f707a6a
for file: GenericFile[data.txt]
[thread #0 - file://input/inbox] DefaultErrorHandler ERROR Failed
delivery for (MessageId: ID- PC-56648-1393004785733-0-69 on ExchangeId:
ID-vgsc-PC-56648-1393004785733-0-70). Exhausted after delivery attempt: 1
caught: org.springframework.jdbc.UncategorizedSQLException:
PreparedStatementCallback; uncategorized SQLException for SQL [insert into
palyer (id, name, city) values (?,?,?)]; SQL state [null]; error code [0];
Number of parameters mismatch. Expected: 3, was:2; nested exception is
java.sql.SQLException: Number of parameters mismatch. Expected: 3, was:2
org.springframework.jdbc.UncategorizedSQLException:
PreparedStatementCallback; uncategorized SQLException for SQL [insert into
palyer (id, name, city) values (?,?,?)];
SQL state [null]; error code [0]; Number of parameters mismatch. Expected:
3, was:2;
nested exception is java.sql.SQLException: Number of parameters mismatch.
Expected: 3, was:2