/ / Ottenere errori in executeUpdate Java MySQL - java, mysql, sql, jdbc

Ottenere errori in executeUpdate Java MySQL - java, mysql, sql, jdbc

Sto cercando di impostare "TUTTI I PRIVILEGI" da Java sul database MySQL remoto test e utente test . Ecco un frammento del mio codice:

Class.forName("com.mysql.jdbc.Driver");
Connection con = null;
con = (Connection) DriverManager.getConnection("jdbc:mysql://xx.xxx.xxx.xx:3306/?user=root&password=pswrd");

Statement st = con.createStatement();
int res = st.executeUpdate("GRANT ALL PRIVILEGES ON test.* TO "test"@"%" IDENTIFIED BY "12345";");

Niente di straordinario. Tutte le query degli utenti root funzionano bene, ma in questo caso partucular sto ottenendo un errore:

Exception in thread "main"   com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user "root"@"%" to database "test"

Cosa ho fatto di sbagliato?

AGGIORNARE

Qui "s risposta. Quindi, il problema non è stato risolto ...

risposte:

0 per risposta № 1

Prova a stabilire una connessione con

DriverManager.getConnection("jdbc:mysql://hostname:port/dbname","username", "password");

0 per risposta № 2

Assicurati che "root @ yourHost" (specialmente da yourHost) identificato da "pswrd" abbia i diritti per gestire i privilegi su questo database.


0 per risposta № 3

prova ad aggiungere host come questo "test" @ "il vostro ospite"