Running stored proc from Java : mysql

05/02/2018


New to MySQL and I’ve been working on this for some time. I’ve gotten my Java code sorted out so that I know it’s passing the correct username/password to the stored proc, but there is an issue with the stored proc itself – maybe the way I’m calling it. Any help is greatly appreciated…

checkLogin stored proc:
CREATE DEFINER=`U03zcv`@`%` PROCEDURE `checkLogin`(checkUser varchar(50),checkPassword              varChar(50),OUT result int)
BEGIN

if exists(select * from user where userName = checkUser and password = checkPassword) then 
set result = 1;
else
set result = 0;
end if;
END

Running this from MySQL workbench
call checkLogin(‘test’, ‘test’, @result)

And all I get is a message saying 0 rows affected.

Java:

CallableStatement cs = con.prepareCall("{call checkLogin(?, ?)}");
cs.setString(1, userName);
cs.setString(2, passWord);

Is there something I need to do to the stored proc or the way I’m calling it?

Thank you

قالب وردپرس