使用JDBC调用存储过程时的注意事项

来源:互联网 发布:淘宝商城我淘我喜欢 编辑:程序博客网 时间:2024/05/19 00:12
在JAVA中调用prepareCall()方法调用存储过程的时候,有时会遇到以下报错:
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
 
经过查阅资料得知,在调用prepareCall()的时候,不光用户要有execute的权限,还需要对mysql.proc具有访问权限。否则它无法访问metadata。所以解决的办法就是除了应该具有相应库的execute权限外,还要执行以下命令,使用户获得mysql.proc的访问权限:
grant select on mysql.proc touser@host;
flush privileges;
原创粉丝点击