我正在尝试使用 jdbcTemplate 执行存储过程,但我不断收到错误消息,指出 GetEvents 需要 0 个参数。任何人都可以解释为什么或有更好的方法来执行这个存储过程吗?
我得到的错误是:
org.springframework.dao.InvalidDataAccessApiUsageException: SQL [CALL GetEvents(?, ?, ?)]: given 3 parameters but expected 0
程序
mysql> CREATE PROCEDURE GetEvents(IN search_table VARCHAR(255), IN start TIMESTAMP, IN end TIMESTAMP)
-> BEGIN
-> SELECT COUNT(*)
-> FROM search_table
-> WHERE time >= start AND time <= end;
-> END //
Query OK, 0 rows affected (0.02 sec)
爪哇
public int getEnterExitsAll(DateTime start, DateTime end) {
Map<String, String> params = new HashMap<String, String>();
params.put("search_table", TABLE_ENEX);
params.put("start", start.toString());
params.put("end", end.toString());
return template.queryForInt("CALL GetEvents(?, ?, ?)", params);