这是我的Java DSL路线:
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");
控制台显示格式正确的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
两个绑定变量都有值,所以它不是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}
然而甲骨文正在回归:
ORA-00947: not enough values
为了完整性,我的配置是:
<!-- 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>
最初的陈述有15列&amp;值并给出了同样的错误。顺便说一下,所有表格列都可以为空。
答案 0 :(得分:0)
由于VALUES
的语法,值应该用括号()
VALUES ?, ?
所以,它应该是
.log(LoggingLevel.INFO, "Inserting into PERSON values: ${body}")
.to("sql:INSERT INTO person (given_name, family_name) VALUES(" +
":#givenName, :#familyName)");