I am trying to call a stored procedure by parameter name:
int processId = 1;
CallableStatement stmt = conn.prepareCall("{call get_process_log_latest(?)}");
stmt.setInt("process_id", processId);
But setInt() throws a NullPointerException:
However, stmt is not null; the exception is thrown from within setInt() on line 2065 from the method getNamedParamIndex() at line 1381.
The stored procedure:
DELIMITER $$
CREATE PROCEDURE `get_process_log_latest`(
IN process_id INT
)
BEGIN
SELECT
id,
start_time,
end_time
FROM process_logs pl
WHERE pl.process_id = process_id
ORDER BY id DESC
LIMIT 1;
END$$
DELIMITER ;
I am using JDK 8, mysql-connector-java-5.1.38, and MySQL 5.7.12.
Do you know what I may be doing wrong?
UPDATE
Authenticated into MySQL with account used by Java and used
SELECT * FROM information_schema.parameters
WHERE parameter_name = 'process_id';
to confirm the parameter name of the stored procedure and that the account has metadata privileges.