Bug #80722 JDBC Driver reports INOUT parameter as not an output parameter
Submitted: 14 Mar 2016 8:30 Modified: 14 Mar 2016 12:24
Reporter: Kwaku T Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.38 OS:Windows (Windows 10 Home Premium)
Assigned to: CPU Architecture:Any
Tags: CallableStatement, escaped, INOUT

[14 Mar 2016 8:30] Kwaku T
Description:
A call to CallableStatement.registerOutParameter() throws Exception: Parameter X is not an OUT parameter. This happens when the database name contains non standard characters (eg '-') and must be escaped

How to repeat:
Create stored procedure ex:
CREATE PROCEDURE `getUsers`(IN `_userid` INT, INOUT `_maxcount` INT)
	LANGUAGE SQL
	NOT DETERMINISTIC
	CONTAINS SQL
	SQL SECURITY DEFINER
	COMMENT ''
BEGIN
	SELECT _maxcount=count(uid) from tm_user WHERE uid=_userid;
	SELECT * FROM tm_user WHERE uid=_userid;
END

in a database with non standard characters ex user-database

Connect to database (JDBC) and call ex:

Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/user-database");

CallableStatment call = conn.prepareCall("{ call `user-database`.getUsers(?, ?)}");

call.registerOutParameter(2,Types.Integer);
//Exception is thrown here
[14 Mar 2016 12:24] Filipe Silva
Hi Kwaku,

This is a duplicate of Bug#79561.

In the meantime you should be able to avoid this issue by not mixing quoted and unquoted identifiers, i.e., it should work if your code was written as:

CallableStatment call = conn.prepareCall("{ call `user-database`.`getUsers`(?, ?)}");

Thank you,