我在RedHat Jboss Fuse(karaf版本6.2.1)中开发了一个Apache Camel路由。 当我尝试执行一个插入查询,即必须调用一个序列,进入数据源(Microsoft Sqlserver 2012)时,我得到一个与参数个数相关的sql错误。
Apache Camel查询:
<to id="insertStartToDB" uri="sql:INSERT INTO dbo.conart_transactions (PK_ID,TRANS_ID,Date_insert,Date_start_flow,Date_end_flow,Flow_name,direction,status,status_descr,aux_1, aux_2,aux_3,aux_4,BLOB) VALUES (NEXT VALUE FOR transaction_pkid_seq,:#TRANS_ID,:#DATE_INSERT,:#DATE_START,:#DATE_END,:#FLOW_NAME,:#DIRECTION,:#STATUS,:#STATUS_DESCR,:#AUX_1,:#AUX_2,:#AUX_3,:#AUX_4,:#BLOB)?dataSource=sqlServerDS"/>
返回错误:
["org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; Number of parameters mismatch. Expected: 14, was: 13; nested exception is java.sql.SQLException: Number of parameters mismatch. Expected: 14, was: 13","\tat org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)[142:org.apache.servicemix.bundles.spring-jdbc:3.2.16.RELEASE_1][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jdbc:3.2.16.RELEASE_1]","\tat org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)[142:org.apache.servicemix.bundles.spring-jdbc:3.2.16.RELEASE_1][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jdbc:3.2.16.RELEASE_1]","\tat org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)[142:org.apache.servicemix.bundles.spring-jdbc:3.2.16.RELEASE_1][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jdbc:3.2.16.RELEASE_1]","\tat org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:605)[142:org.apache.servicemix.bundles.spring-jdbc:3.2.16.RELEASE_1][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jdbc:3.2.16.RELEASE_1]","\tat org.apache.camel.component.sql.SqlProducer.process(SqlProducer.java:107)[123:org.apache.camel.camel-sql:2.17.0.redhat-630187][org.apache.camel:camel-sql:2.17.0.redhat-630187]","\tat org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:117)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.Pipeline.process(Pipeline.java:121)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.Pipeline.process(Pipeline.java:83)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:91)[120:org.apache.camel.camel-core:2.17.0.redhat-630187][org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]","\tat org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:112)[121:org.apache.camel.camel-jms:2.17.0.redhat-630187][org.apache.camel:camel-jms:2.17.0.redhat-630187]","\tat org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:555)[143:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2]","\tat org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:515)[143:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2]","\tat org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:485)[143:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2]","\tat org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)[143:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2]","\tat org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)[143:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2]","\tat org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1103)[143:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2]","\tat org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1095)[143:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2]","\tat org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:992)[143:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jms:3.2.16.RELEASE_2]","\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_111]","\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_111]","\tat java.lang.Thread.run(Thread.java:745)[:1.8.0_111]","Caused by: java.sql.SQLException: Number of parameters mismatch. Expected: 14, was: 13","\tat org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy.populateStatement(DefaultSqlPrepareStatementStrategy.java:153)[123:org.apache.camel.camel-sql:2.17.0.redhat-630187][org.apache.camel:camel-sql:2.17.0.redhat-630187]","\tat org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:137)[123:org.apache.camel.camel-sql:2.17.0.redhat-630187][org.apache.camel:camel-sql:2.17.0.redhat-630187]","\tat org.apache.camel.component.sql.SqlProducer$2.doInPreparedStatement(SqlProducer.java:107)[123:org.apache.camel.camel-sql:2.17.0.redhat-630187][org.apache.camel:camel-sql:2.17.0.redhat-630187]","\tat org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:589)[142:org.apache.servicemix.bundles.spring-jdbc:3.2.16.RELEASE_1][org.apache.servicemix.bundles:org.apache.servicemix.bundles.spring-jdbc:3.2.16.RELEASE_1]","\t... 29 more"]
我想这与插入的第一个值相关(“NEXT VALUE FOR transaction_pkid_seq”),但我无法理解为什么不起作用。 提前谢谢。