Bug #90376 registerOutParameter() throwing SQLException: Parameter number 2 is not OUT Para
Submitted: 11 Apr 2018 2:51 Modified: 11 Apr 2018 11:05
Reporter: Ravitez Dondeti Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.34 OS:Linux
Assigned to: CPU Architecture:x86
Tags: registerOutParameter()

[11 Apr 2018 2:51] Ravitez Dondeti
Description:
Issue :
-------
	System randomly generates the mentioned exception and recovers itself.
	
System Env:
------------
	MYSQL configured in Master Slave Mode

Stored procedure
----------------

DROP PROCEDURE IF EXISTS getUserName;
delimiter $$
CREATE PROCEDURE getUserName(userIndex int, out userId int)
BEGIN
set userId:=(select u.userId from User u where u.id=userIndex);
END$$
DELIMITER ;

Execution :
-----------
callableStatement=con.prepareCall("{call getUserName(?,?)}") ;
			callableStatement.setInt(1,100) ; ========== 100 is the user-index
			callableStatement.registerOutParameter(2, Types.BIGINT); =================== > random exception
			resultSet1=callableStatement.executeQuery() ;

Exception :
-----------
Caused by: java.sql.SQLException: Parameter number 2 is not an OUT parameter
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:924)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:870)
        at com.mysql.jdbc.CallableStatement.checkIsOutputParam(CallableStatement.java:659)
        at com.mysql.jdbc.CallableStatement.registerOutParameter(CallableStatement.java:1860)

		Please share your comments.
		Thank you.
		

How to repeat:
its not reproducible consistently
[11 Apr 2018 5:58] Chiranjeevi Battula
Hello  Ravitez,

Thank you for the bug report.
I tried to reproduce the issue at my end using MySQL Connector / J 5.1.46 and MySQL 5.7.21 but not seeing any issues.
Please recheck your database connections and procedures.

Thanks,
Chiranjeevi.
[11 Apr 2018 11:05] Ravitez Dondeti
Hi Chiranjeevi,
              Thank you for the update.
              I'm not able to reproduce it consistently either.
              is there any way to dump data from callablestatement or in 
              Connection object.
              could you please advise on how to check the connection info (is it via SHOW PROCESESSLIST)
              Thank you for the help.

Regards,
Ravitez.D