Following is the oracle proc call from java using binded params -
String GET_TEST_ID = "{call PKG_TEST.prc_gettestid(:PARAM1, :PARAM2, :PARAM3, :OUTPARAM1)}";
String id = (String)getJdbcTemplate().execute
( GET_TEST_ID, new CallableStatementCallback()
{
public Object doInCallableStatement(CallableStatement callableStatement) throws SQLException, DataAccessException
{
callableStatement.registerOutParameter("OUTPARAM1", java.sql.Types.VARCHAR);
callableStatement.setLong("PARAM1", param1);
callableStatement.setLong("PARAM2", param2);
callableStatement.setLong("PARAM3", param3);
callableStatement.execute();
String testId = callableStatement.getString(OUTPARAM1);
return testId;
}
}
);
But it does not seem to work. In the proc when I log values I am getting values of PARAM1 in PARAM2 and that of PARAM2 in PARAM3.
?
. The parameter name you pass to thesetXY()
method is the parameter name as specified in the procedure declaration, not the name of the bind placeholder.void setString(String parameterName, String x)
in CallableStatement.