This question is similar to: Mysql - Stored procedure OUT variable return null, sadly their solutions did not work for me.
I have a database populated with data about who used my program and when, and I am trying to create a stored procedure in MySql to retrieve all the data and send it to my java servlet, where it will be processed.
This is what I have currently for my Stored Procedure:
CREATE DEFINER=`root`@`localhost`
PROCEDURE `getTableData`(OUT time VARCHAR(45), OUT fName VARCHAR(45),
OUT lName VARCHAR(45), OUT rVar INT)
BEGIN
SELECT rqTime, name, lastName, requestVar FROM pdata.userlist;
END
Here is how I call the query in Java:
CallableStatement stmt = null;
ResultSet rs = null;
String sqlQuery = "{call getTableData (?, ?, ?, ?)}";
stmt = conn.prepareCall(sqlQuery);
stmt.registerOutParameter(1, java.sql.Types.VARCHAR);
stmt.registerOutParameter(2, java.sql.Types.VARCHAR);
stmt.registerOutParameter(3, java.sql.Types.VARCHAR);
stmt.registerOutParameter(4, java.sql.Types.INTEGER);
stmt.execute();
When I try to call this stored procedure in Java (I've tried using result sets and the normal getString(), etc) all values return null.
My table design is along the lines of:
Request Time (millis), name, lastName, requestID
1402341252155, John, Doe, 11
Any help would be greatly appreciated. I feel as though the problem lies in the stored procedure itself, particularly the how I select the variables from the the table and assign them to the "out" parameters.
Thanks!