문제

I'm trying to execute a stored procedure using jdbcTemplate but I keep getting an error saying that GetEvents expects 0 arguments. Can anyone shed some light on why or is there a better way to execute this stored procedure?

The error I'm getting is:
org.springframework.dao.InvalidDataAccessApiUsageException: SQL [CALL GetEvents(?, ?, ?)]: given 3 parameters but expected 0

Procedure

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)

Java

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);

올바른 솔루션이 없습니다

다른 팁

I suspect, it's happening because of your variable naming (end being reserved keyword). Please try renaming end to endTime and start to startTime or something similar.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top