0

trying to call a DB2 procedure from java through spring:

SimpleJdbcCall call = new SimpleJdbcCall(dataSource)
.withSchemaName("schemaName")
.withProcedureName("proc1")
.declareParameters(
new SqlParameter("param2", Types.CHAR),
new SqlOutParameter("output1", Types.CHAR));
MapSqlParameterSource params = new 
MapSqlParameterSource();
params.addValue("param2", "val1");
Map<String, Object> result = call.execute(params);

Whatever i do, i get error db2 error 42884, -440. If i call any other procedure without parameters, it works fine.

CallableStatementCallback; bad SQL grammar [{call schemaName. proc1()}]; nested exception is com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-440, SQLSTATE=42884, SQLERRMC=PROCEDURE;XDJA00.LAJA0204, DRIVER=4.19.26

It is like, the code does not accept the parameters..

I changed the calling to old school java call:

CallableStatement cs = con.prepareCall("CALL schemaName.proc1(?,?)");
cs.setString(1, "f");
cs.registerOutParameter(2, Types.CHAR);
cs.execute();
System.out.println(cs.getString(2));

It works perfectly fine, any idea what might be wrong ?

Parameswar
  • 1,951
  • 9
  • 34
  • 57

0 Answers0