如何使用新的数据库端点从Mule 3.5调用存储过程 [英] How to call stored procedure from Mule 3.5 with new Database endpoint

查看:102
本文介绍了如何使用新的数据库端点从Mule 3.5调用存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用存储过程测试Mule的Mule 3.5的新数据库连接器...(参考:- http://www.mulesoft.org/documentation/display/current/Database+Connector ).我有以下存储过程:-

I was testing Mule's new Database connector of Mule 3.5 with Stored Procedure ... (Reference :- http://www.mulesoft.org/documentation/display/current/Database+Connector ).. I had a following Stored Procedure :-

ALTER PROCEDURE [dbo].[sp_retrieveData]
 @Id  int
AS
Select * from getData Where ID = @Id

哪个在Mule的旧JDBC连接器中工作正常?...我以前使用以下语法从JDBC端点调用存储过程:-<jdbc-ee:query key="RetriveQuery" value="CALL sp_retrieveData(${Id})"/>哪个工作正常...但是问题出在Mule 3.5中新的数据库端点,我无法调用相同的存储过程.我的Mule配置为:-

Which is working fine in Mule's old JDBC connector ... I used to call the stored procedure from the JDBC endpoint using the following syntax :- <jdbc-ee:query key="RetriveQuery" value="CALL sp_retrieveData(${Id})"/> Which worked fine ... But now the issue is in the Mule 3.5 new Database end point I am unable to call the same Stored Procedure ... My Mule configuration is :-

<db:stored-procedure config-ref="Generic_Database_Configuration" doc:name="Database">
   <db:parameterized-query><![CDATA[CALL sp_retrieveData(58)]]></db:parameterized-query>
   <db:in-param name="Id" type="INTEGER" value="58"/>
  </db:stored-procedure>

所以,我的问题是如何使用新的DB端点调用存储过程...有人尝试过吗???? ...请帮助...

So, My question is how can I call Stored Procedure with the new DB endpoint ... Had anyone tried it ???... Please help ...

更新:- 我得到以下异常:-

Update:- The following exception I get :-

Exception stack is:
1. The index 1 is out of range. (com.microsoft.sqlserver.jdbc.SQLServerException)
  com.microsoft.sqlserver.jdbc.SQLServerException:170 (null)
2. The index 1 is out of range. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: String (org.mule.api.MessagingException)
  org.mule.module.db.internal.processor.AbstractDbMessageProcessor:81 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
com.microsoft.sqlserver.jdbc.SQLServerException: The index 1 is out of range.
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setterGetParam(SQLServerPreparedStatement.java:698)
    at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObject(SQLServerPreparedStatement.java:928)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

推荐答案

IMO最好的文档是它的测试. DB模块的存储过程测试在这里: https://github.com/mulesoft/mule/tree/mule-3.5.0/modules/db/src/test/resources/integration/storedprocedure

IMO the best documentation for anything are its tests. The stored procedure tests for the DB module are here: https://github.com/mulesoft/mule/tree/mule-3.5.0/modules/db/src/test/resources/integration/storedprocedure

基于这些,以下应该起作用:

Based on these, the following should work:

<db:stored-procedure config-ref="Generic_Database_Configuration">
  <db:parameterized-query>{ call sp_retrieveData(:Id) }</db:parameterized-query>
  <db:in-param name="Id" value="58" />
</db:stored-procedure>

(我还没有测试过)

这篇关于如何使用新的数据库端点从Mule 3.5调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆