I'm writing a java application that communicates with a MySQL server. This server has a few stored procedures I need to call, but when I try to call them I get the following error:
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.
SQL State:S1000
error code:0
I tried adding noAccessToProcedureBodies=true to the connection string, but it kept giving me the same error. I then proceeded to GRANT SELECT on mysql.proc, which should solve the problem, and since I have a user (creautenti) which is the user admin and creates all the others, i added with grant option to the statement, so that it would be able to grant the same privilege to the other users when creating them, but even if I call for each new user GRANT SELECT ON mysql.proc, it still won't work. I mean, when I log in as creautenti and call a procedure, it works just fine, but if I try to do it with any other user I get the error I wrote above. What's also strange is that I'm able to call the procedures from mysql workbench (logged in as any user I created through creautenti) even if I don't call grant select on mysql.proc, only with the execute privilege on the schema that contains the sprocs.
this is the method I call to create new users, which seems not to give the correct privileges:
public static boolean creazioneUtente(String user, String password) throws EccezioneDaMostrare{
if(apriConnessione(CREA_UTENTI_USER, CREA_UTENTI_PW, false)){
try{
conn.setAutoCommit(false);
String sqlCommand="CREATE USER ? @'%' IDENTIFIED BY PASSWORD ?";
String sqlCommandGrant="GRANT EXECUTE ON salvataggi.* TO ? ";
String sqlCommandGrantEx="GRANT SELECT ON mysql.proc TO ?";
PreparedStatement s=conn.prepareStatement(sqlCommand);
PreparedStatement sGrant=conn.prepareStatement(sqlCommandGrant);
PreparedStatement sGrantEx=conn.prepareStatement(sqlCommandGrantEx);
s.setString(1, user);
sGrant.setString(1, user);
sGrantEx.setString(1, user);
s.setString(2, mySQLPASSWORD(password));
s.execute();
sGrant.execute();
sGrantEx.execute();
conn.commit();
conn.setAutoCommit(true);
chiudiConnessione();
return true;
}
catch(SQLException e){
try {
conn.rollback();
} catch (SQLException e1) {
String msg=String.format("Errore durante la connessione al server MySQL:\n Messaggio:%s \n Stato SQL:%s \n Codice errore:%s", e.getMessage(), e.getSQLState(), e.getErrorCode());
throw new EccezioneDaMostrare(msg);
}
chiudiConnessione();
return false;
}
}
else
return false;
}
apriConnessione() opens a connection, and chiudiConnessione() closes it.
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.
SQL State:S1000
error code:0
I tried adding noAccessToProcedureBodies=true to the connection string, but it kept giving me the same error. I then proceeded to GRANT SELECT on mysql.proc, which should solve the problem, and since I have a user (creautenti) which is the user admin and creates all the others, i added with grant option to the statement, so that it would be able to grant the same privilege to the other users when creating them, but even if I call for each new user GRANT SELECT ON mysql.proc, it still won't work. I mean, when I log in as creautenti and call a procedure, it works just fine, but if I try to do it with any other user I get the error I wrote above. What's also strange is that I'm able to call the procedures from mysql workbench (logged in as any user I created through creautenti) even if I don't call grant select on mysql.proc, only with the execute privilege on the schema that contains the sprocs.
this is the method I call to create new users, which seems not to give the correct privileges:
public static boolean creazioneUtente(String user, String password) throws EccezioneDaMostrare{
if(apriConnessione(CREA_UTENTI_USER, CREA_UTENTI_PW, false)){
try{
conn.setAutoCommit(false);
String sqlCommand="CREATE USER ? @'%' IDENTIFIED BY PASSWORD ?";
String sqlCommandGrant="GRANT EXECUTE ON salvataggi.* TO ? ";
String sqlCommandGrantEx="GRANT SELECT ON mysql.proc TO ?";
PreparedStatement s=conn.prepareStatement(sqlCommand);
PreparedStatement sGrant=conn.prepareStatement(sqlCommandGrant);
PreparedStatement sGrantEx=conn.prepareStatement(sqlCommandGrantEx);
s.setString(1, user);
sGrant.setString(1, user);
sGrantEx.setString(1, user);
s.setString(2, mySQLPASSWORD(password));
s.execute();
sGrant.execute();
sGrantEx.execute();
conn.commit();
conn.setAutoCommit(true);
chiudiConnessione();
return true;
}
catch(SQLException e){
try {
conn.rollback();
} catch (SQLException e1) {
String msg=String.format("Errore durante la connessione al server MySQL:\n Messaggio:%s \n Stato SQL:%s \n Codice errore:%s", e.getMessage(), e.getSQLState(), e.getErrorCode());
throw new EccezioneDaMostrare(msg);
}
chiudiConnessione();
return false;
}
}
else
return false;
}
apriConnessione() opens a connection, and chiudiConnessione() closes it.