This is my Java DSL route:
from("seda:singlePersonChannel")
.log(LoggingLevel.INFO, "Person bean: ${body}")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Person person = exchange.getIn().getBody(Person.class);
exchange.getOut().setBody(person.toSqlMap());
}
})
.log(LoggingLevel.INFO, "Inserting into PERSON values: ${body}")
.to("sql:INSERT INTO person (given_name, family_name) VALUES " +
":#givenName, :#familyName");
The console shows properly formatted DML:
Sql = INSERT INTO person (given_name, family_name) VALUES :1 , :2 , OriginalSql = INSERT INTO person (given_name, family_name) VALUES ?, ?, Error Msg = ORA-00947: not enough values
Both bind variables have values, so it's not a problem with nulls:
15:20:58.622 INFO [Camel (camel-1) thread #1 - seda://singlePersonChannel][route2] Person bean: Person{givenName=Given Name -593520961, familyName=Family Name 1883898232}
15:20:58.622 INFO [Camel (camel-1) thread #1 - seda://singlePersonChannel][route2] Inserting into PERSON values: {givenName=Given Name -593520961, familyName=Family Name 1883898232}
And yet Oracle is returning:
ORA-00947: not enough values
For the sake of completness my config is:
<!-- the JDBC data source -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@DB-SVR-1:1521:DEV112A" />
<property name="username" value="integration" />
<property name="password" value="integration" />
</bean>
<bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="dataSource" />
</bean>
The original statement had 15 columns & values and was giving the same error. BTW, all the table columns are nullable.
It's because of syntax of
VALUES
, values should be inclosed by brackets()
So, it should be