Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top