Parameter number 2 is not an OUT parameter

孤者浪人 提交于 2019-12-02 21:29:55

问题


String sqlString = "{CALL MyStoredProcedure(?,?)}";

CallableStatement sqlStm = connection.prepareCall(sqlString);

sqlStm.setString(1, username);
sqlStm.registerOutParameter(2, Types.DECIMAL, 0); // <---- ERROR
sqlStm.execute();

This is my error stacktrace:

java.sql.SQLException: Parameter number 2 is not an OUT parameter
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
    at com.mysql.jdbc.CallableStatement.checkIsOutputParam(CallableStatement.java:690)
    at com.mysql.jdbc.CallableStatement.registerOutParameter(CallableStatement.java:1881)
    at com.mysql.jdbc.CallableStatement.registerOutParameter(CallableStatement.java:1890)
    at com.isb.igt.database.StoredProcedures.preparationCalls(StoredProcedures.java:40)
    at com.isb.igt.database.StoredProcedures.main(StoredProcedures.java:236)

The procedure first line:

CREATE DEFINER=devel@11.22.33.44 PROCEDURE MyStoredProcedure(IN login VARCHAR(255), OUT variable DECIMAL(20,2)

I can't figure out how to get it to work.

Thank you


回答1:


Function call should look like {? = call MyStoredProcedure(?)}



来源:https://stackoverflow.com/questions/19380074/parameter-number-2-is-not-an-out-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!