Mysql5的存储过程的权限Bug

晚上搞了半天procedure的问题,提示:
java.sql.SQLException: Driver requires declaration of procedure to either contain a ‘\nbegin’ or ‘\n’ to follow argument declaration, or SELECT privilege on mysql.proc to parse column types.
 at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:6953)
 at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:2721)
 at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:1048)
 at com.mysql.jdbc.CallableStatement.<init>(CallableStatement.java:83)
 at com.mysql.jdbc.Connection.prepareCall(Connection.java:1255)
 at com.mysql.jdbc.Connection.prepareCall(Connection.java:1232)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at com.mchange.v2.c3p0.stmt.GooGooStatementCache$2.run(GooGooStatementCache.java:333)
 at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:354)
找了半天存储过程的问题,因为都着眼于’\nbegin’ or ‘\n’这个地方了,重建了procedure也不起作用,找不到问题所在。
仔细思考,换用了root登陆就可以了。感觉明显是权限privileges的问题。
所以其实应该是这个提示or SELECT privilege on mysql.proc to parse column types。
可是google不到这个问题所在,因为没有mysql.proc这个权限,但是有人说这是一个bug
后来我发现,其实它是指mysql这个库的proc表的SELECT权限,添加上就工作正常了……
其实原因是这样的,原先测试时使用的xinfangweb的用户有两个,一个是localhost,另一个是%,前者的权限是全的,后者被限制了,哈哈。

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.