Question

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

No correct solution

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top