将日期参数传递给Mule中的jdbc查询

问题描述:

我在Mule中有一个流,我想使用从一个查询中获取的日期参数作为另一个查询的输入。将日期参数传递给Mule中的jdbc查询

​​

当运行这个我不能得到这个工作(请注意,我使用的是Oracle数据库)。我已经在下面列出了这个例外。有没有人遇到过这个?

-------------------------------------------------------------------------------- 
Exception stack is: 
1. Invalid column type(SQL Code: 17004, SQL State: + null) (java.sql.SQLException) 
    oracle.jdbc.driver.DatabaseError:113 (null) 
2. Invalid column type Query: SELECT ID FROM CUSTOMERS WHERE UPDATED < TO_DATE(?,'YYYY-MM-DD HH24:MI:SS') Parameters: [[2000-01-01]](SQL Code: 17004, SQL State: + null) (java.sql.SQLException) 
    org.apache.commons.dbutils.QueryRunner:540 (null) 
3. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jdbc://getCustomerIds, connector=JdbcConnector 
{ 
    name=myConnector 
    lifecycle=start 
    this=668e94 
    numberOfConcurrentTransactedReceivers=4 
    createMultipleTransactedReceivers=false 
    connected=true 
    supportedProtocols=[jdbc] 
    serviceOverrides=<none> 
} 
, name='endpoint.jdbc.getCustomerIds', mep=REQUEST_RESPONSE, properties={queryTimeout=-1}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: ArrayList (org.mule.api.transport.DispatchException) 
    org.mule.transport.AbstractMessageDispatcher:106 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html) 
-------------------------------------------------------------------------------- 
+0

什么记录器输出? – 2012-01-02 17:05:45

+0

'INFO 2012-01-03 08:27:00,030 [scheduler-TalentumESB_Worker-12] org.mule.api.processor.LoggerMessageProcessor:last_poll_end = [2000-01-01]' 接下来是我的例外原来的帖子。 – 2012-01-03 07:32:05

+0

记录器清楚地显示问题出现在选择部分,而不是插入。 – 2012-01-03 16:06:53

问题解决了。问题的部分原因是我从第一个查询中得到的日期变量被存储为一个数组。为了解决这个问题,我挑出第一个元素。除此之外,我删除了第二个sql查询中的to_date()。

这得到数组中的第一个元素:

<enrich target="#[variable:last_poll_end]" source="#[groovy:payload.last_poll_end[0]]"/> 

更新的SQL:

<jdbc:query key="getCustomerIds" value="SELECT id FROM customers WHERE updated &lt; #[variable:last_poll_end]" />