JDBC查询中的Mule括号+替换参数失败

时间:2013-08-27 14:16:48

标签: jdbc mule

我遇到了Mule正在执行外部工作的JDBC查询的问题。如果它还有替换参数,我将括号放入其中就会失败。我想知道MEL是否有一些我不理解的括号问题。

以下(简化)示例在我的流程中正确执行:

    <jdbc:query
        key="QueryStrategy"
        value="SELECT product_strategy FROM licensing.product WHERE product_sku = #[flowVars['productSku']] OR product_sku IS NULL"/>

如果我用常量替换对流变量的引用,我可以添加括号并且它仍然有效:

    <jdbc:query
        key="QueryStrategy"
        value="SELECT product_strategy FROM licensing.product WHERE (product_sku = 'Trial' OR product_sku IS NULL)"/>

但是,当我在替换参数出现时添加括号时,我得到一个例外:

    <jdbc:query
        key="QueryStrategy"
        value="SELECT product_strategy FROM licensing.product WHERE (product_sku = #[flowVars['productSku']] OR product_sku IS NULL)"/>

例外情况如下所示。这是Mule对Microsoft发送的内容或Microsoft JDBC驱动程序中的一些错误的格式问题吗?

修改 这是为org.mule.transport.jdbc打开DEBUG的修改日志。

com.ca.eai.esb.interceptor.EaiLoggingInterceptor FlowBefore | Flow Name: Main | MULE_REMOTE_CLIENT_ADDRESS: /127.0.0.1:59952 | consumerTransId: E0acd42cb-100d-11e3-a264-852205c1b19e | consumerDateTimeSent: null | consumerApp: null | consumerUsername: null | mule.muleId: null | esbTransCode: null | messageSourceName: endpoint.https.localhost.8088.license.requests.r.v1 | currentTimestamp: 2013-08-28 14:09:55.309
org.mule.transport.jdbc.JdbcConnector Borrowing a dispatcher for endpoint: jdbc://QueryStrategy
org.mule.transport.jdbc.JdbcMessageDispatcher Connecting: JdbcMessageDispatcher{this=5764c302, endpoint=jdbc://QueryStrategy, disposed=false}
org.mule.transport.jdbc.JdbcMessageDispatcher Connected: endpoint.outbound.jdbc://QueryStrategy
org.mule.transport.jdbc.JdbcConnector Borrowed a dispatcher for endpoint: jdbc://QueryStrategy = JdbcMessageDispatcher{this=5764c302, endpoint=jdbc://QueryStrategy, disposed=false}
org.mule.transport.jdbc.JdbcConnector Borrowed dispatcher: JdbcMessageDispatcher{this=5764c302, endpoint=jdbc://QueryStrategy, disposed=false}
org.mule.transport.jdbc.sqlstrategy.SelectSqlStatementStrategy Trying to receive a message with a timeout of 10000
org.mule.transport.jdbc.sqlstrategy.SelectSqlStatementStrategy SQL QUERY: SELECT product_strategy, product_id FROM licensing.product WHERE product_name = ? AND (product_sku is null OR product_sku = ? ) ORDER BY product_sku DESC, params = {My Product,My Product}
org.mule.transport.jdbc.JdbcConnector Returning dispatcher for endpoint: jdbc://QueryStrategy = JdbcMessageDispatcher{this=5764c302, endpoint=jdbc://QueryStrategy, disposed=false}
com.ca.eai.esb.interceptor.EaiLoggingInterceptor FlowLast | Flow Name: Main | MULE_REMOTE_CLIENT_ADDRESS: /127.0.0.1:59952 | consumerTransId: E0acd42cb-100d-11e3-a264-852205c1b19e | consumerDateTimeSent: null | consumerApp: null | consumerUsername: null | mule.muleId: null | esbTransCode: null | messageSourceName: endpoint.https.localhost.8088.license.requests.r.v1 | currentTimestamp: 2013-08-28 14:09:55.791 | elapsedTime: 484ms
org.mule.exception.DefaultMessagingExceptionStrategy 
********************************************************************************
Message               : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jdbc://QueryStrategy, connector=JdbcConnector
{
  name=Database
  lifecycle=start
  this=333d612e
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=false
  connected=true
  supportedProtocols=[jdbc]
  serviceOverrides=<none>
}
,  name='endpoint.jdbc.QueryStrategy', 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: String
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'FROM'.(SQL Code: 0, SQL State: + null) (com.microsoft.sqlserver.jdbc.SQLServerException)
  com.microsoft.sqlserver.jdbc.SQLServerException:190 (null)
2. com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'FROM'. Query: SELECT product_strategy, product_id FROM licensing.product WHERE product_name = ? AND (product_sku is null OR product_sku = ? ) ORDER BY product_sku DESC Parameters: [My Product, My Product](SQL Code: 0, SQL State: + null) (java.sql.SQLException)
  org.apache.commons.dbutils.QueryRunner:540 (null)
3. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jdbc://QueryStrategy, connector=JdbcConnector
{
  name=Database
  lifecycle=start
  this=333d612e
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=false
  connected=true
  supportedProtocols=[jdbc]
  serviceOverrides=<none>
}
,  name='endpoint.jdbc.QueryStrategy', 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: String (org.mule.api.transport.DispatchException)
  org.mule.transport.AbstractMessageDispatcher:109 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
com.microsoft.sqlserver.jdbc.SQLServerException: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'FROM'.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
    at com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData.<init>(SQLServerParameterMetaData.java:426)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getParameterMetaData(SQLServerPreparedStatement.java:1532)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

0 个答案:

没有答案