问题
I have created a SP in mysql which takes 6 input parameters and give 2 output parameters. I want to call this from DB lookup. I don't know how to do that. I have tried different-2 codes but no luck. please help.
Synapse Code:
<dblookup>
<connection>
<pool>
<driver>com.mysql.jdbc.Driver</driver>
<property name="autocommit" value="false"/>
<password>root</password>
<user>root</user>
<url>jdbc:mysql://localhost:3308/emp</url>
</pool>
</connection>
<statement>
<sql>
<![CDATA[call MANAGE_MANAGER_DETAIL(?,?,?,?,?,?,@RESULT_CODE, @RESULT_DESC)]]>
</sql>
<parameter expression="synapse:get-property('RequestNumber')" type="VARCHAR"/>
<parameter expression="synapse:get-property('RequestNumber')" type="VARCHAR"/>
<parameter expression="synapse:get-property('RequestNumber')" type="VARCHAR"/>
<parameter expression="synapse:get-property('RequestNumber')" type="VARCHAR"/>
<parameter expression="synapse:get-property('RequestNumber')" type="VARCHAR"/>
<parameter expression="synapse:get-property('RequestNumber')" type="VARCHAR"/>
</statement>
<statement>
<sql>
<![CDATA[SELECT @RESULT_CODE, @RESULT_DESC)]]>
</sql>
<result name="RESULT_CODE" column="RESULT_CODE"/>
<result name="RESULT_DESC" column="RESULT_DESC"/>
</statement>
</dblookup>
Logs:
[2015-11-19 13:38:23,668] DEBUG - DBLookupMediator Setting as parameter : 6 value : 1 as JDBC Type : 12(see java.sql.Typepes)
[2015-11-19 13:38:23,669] DEBUG - DBLookupMediator Successfully prepared
statement :call MANAGE_MANAGER_DETAIL(?,?,?,?,?,?,@RESULT_CODE, @RESULT_DESC)
against DataSource : jdbc:mysql://localhost:3308/emp=[2015-11-19 13:38:23,679]
ERROR - DBLookupMediator Error executing statement :
call MANAGE_MANAGER_DETAIL(?,?,?,?,?,?,@RESULT_CODE, @RESULT_DESC) against
DataSource : jdbc:mysql://localhost:3308/emp
java.sql.SQLException: ResultSet is from UPDATE. No Data. at com.mysql.jdbc.ResultSet.next(ResultSet.java:6129)
at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:207)
at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:207)
at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:207
回答1:
I think that DBLookup does not support output parameters in the way you put them.
Try to get output like this
<statement>
<sql>call getCompany(?)</sql>
<parameter expression="//m0:getQuote/m0:request/m0:symbol"
xmlns:m0="http://services.samples" type="VARCHAR"/>
<result name="company_id" column="id"/>
</statement>
Look at the link for the full sample.
来源:https://stackoverflow.com/questions/33793428/not-getting-out-parameter-of-mysql-stored-procedure-in-wso2-esb-dblookup