java调用存储过程时会使用到的方法
public void produceCallExecute(final String sql, final Object... params)
throws SystemException {
template.execute(new CallableStatementCreator() {
public CallableStatement createCallableStatement(Connection con)
throws SQLException {
// TODO Auto-generated method stub
CallableStatement call = con.prepareCall(sql);
int index = 1;
for (Object param : params) {
call.setObject(index, param);
index++;
}
return call;
}
}, new CallableStatementCallback<Object>() {
public Object doInCallableStatement(CallableStatement cs)
throws SQLException, DataAccessException {
// TODO Auto-generated method stub
cs.execute();
return null;
}
});
}