Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Quick Tip: Granting Access to Meta-Data on MySQL

DZone's Guide to

Quick Tip: Granting Access to Meta-Data on MySQL

If you have root access to your MySQL database then you can simply run a query on the database to resolve the problem.

· Database Zone
Free Resource

Whether you work in SQL Server Management Studio or Visual Studio, Redgate tools integrate with your existing infrastructure, enabling you to align DevOps for your applications with DevOps for your SQL Server databases. Discover true Database DevOps, brought to you in partnership with Redgate.

Ever seen this exception in your log files when working with MySQL as your database back-end?

User does not have access to metadata required to determine storedprocedure parameter types. If rights can not be granted, configureconnection with "noAccessToProcedureBodies=true" to have drivergenerate parameters that represent INOUT strings irregardless of actualparameter types.

Well, I have come across this now a couple of times and for some reasonI just cannot remember how to either configure the connection to usethe "noAccessToProcedureBodies=true"switch or what the exact SQL is that I need to execute to give the userthe appropriate access. This time however I decided it is time that Iplace this information somewhere I can easily find it again and whereit can potentially also help out others. Believe me to find thesolution to this via Google searches takes a while... So, I naturallythought of the DZone network and the SQL zone in particular. Enoughtalk then, below follows the solutions for both scenarios. For thesecond one however, you will need a version of the Connector/J equal toor above version 5.0.3.

If you have root access to your MySQL database then you can simply run a query on the database to resolve the problem. What the query will do is give the specified user the needed rights on the mysql.proc table. This takes the form of the following GRANT SQL query:

GRANT [SELECT, INSERT, UPDATE] ON `mysql`.`proc` TO 'myuser'@'myhost';

That's it, after running this query on the database the above exceptiongoes away. If however, you do not have the needed root access to runthis query on the database then below is the connection string to useto get around this problem. Very simple, just add &noAccessToProcedureBodies=true to your current connection string and you are done.

String connectionURL = "jdbc:mysql://localhost:3306/mydatabase?user=myuser&password=mypassword&noAccessToProcedureBodies=true"

I sincerely hope this tip will help out someone else. If not, well,then at least I now know where to go the next time I run into thisproblem :)

It’s easier than you think to extend DevOps practices to SQL Server with Redgate tools. Discover how to introduce true Database DevOps, brought to you in partnership with Redgate

Topics:
sql ,mysql ,metadata access ,database

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}