Bug #26143 DEFINER='xxx' result in NPE during prepareCall()
Submitted: 7 Feb 2007 11:39 Modified: 8 Feb 2007 7:15
Reporter: Klaus Halfmann Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.0.4 OS:Any (ANY)
Assigned to: CPU Architecture:Any

[7 Feb 2007 11:39] Klaus Halfmann
Description:

Trying to call a PROCEDURE with DEFINE=''
results in a 

NullPointerException

How to repeat:
Given the follwing Declaration:

CREATE DEFINER='xxx'
	PROCEDURE SP(I INT)
       COMMENT ''
BEGIN
	SELECT I * 10;
END

The follwoing code:

MysqlConnectionPoolDataSource myDs = new MysqlConnectionPoolDataSource();
myDs.setServerName  ("localhost");
myDs.setDatabaseName("ucs");
myDs.setPassword    ("ucs");
myDs.setUser        ("ucs");
Connection        con = myDs.getConnection();

results in
Exception in thread "main" java.lang.NullPointerException
	at com.mysql.jdbc.StringUtils.indexOfIgnoreCaseRespectQuotes(StringUtils.java:959)
	at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:1296)
	at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:3670)
	at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:702)
	at com.mysql.jdbc.CallableStatement.<init>(CallableStatement.java:513)
	at com.mysql.jdbc.Connection.parseCallableStatement(Connection.java:4422)
	at com.mysql.jdbc.Connection.prepareCall(Connection.java:4496)
	at com.mysql.jdbc.Connection.prepareCall(Connection.java:4470)
	at SPTest.main(SPTest.java:22)

Suggested fix:

- No Idea - depends on some MetaData parsing ?
Look in com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes
[7 Feb 2007 20:51] Mark Matthews
I just tested this with the HEAD of 5.0, and can't repeat it (there's some fixes for just this area of code in HEAD).

Could you test with your stored procedure using a nightly snapshot of 5.0 from http://downloads.mysql.com/snapshots.php#connector-j please?
[8 Feb 2007 7:15] Klaus Halfmann
#1 Much better error message, you now can drop my Feature Request:

java.sql.SQLException: User does not have access to metadata required to determine stored procedure parameter types. If rights can not be granted, configure connection with "noAccessToProcedureBodies=true" to have driver generate parameters that represent INOUT strings irregardless of actual parameter types.

#2 
  mysql-connector-java-5.0-nightly-20070208-bin.jar fixed it.

Thanks for your prompt response.

(I hope the security model for StoredProcedures will be refined in 5.1.
 As it is now its OK for us but not in general)