Link to home
Start Free TrialLog in
Avatar of jeff1919
jeff1919

asked on

java.sql.SQLException: Invalid authorization specification

I am running a testing java program and get the following error message. I have no problem login to mysql with the same username and password. I have tried to connect to the 'test' database without username and password and got no error.
(That means the jdbc driver is working fine.) i have tried to grant all privileges to the user and still got the same error messages. Please help.

===================================================================
java.sql.SQLException: Invalid authorization specification,  message from server: "Access denied for user: 'epuser@interfacezone.net' (Using password: YES)"
================================================================
import java.sql.*;

public class TestMysql
{
  public static void main(String args[]) {
    try {
      /* Test loading driver */

      String driver = "com.mysql.jdbc.Driver";

      System.out.println( "\n=> loading driver:" );
      Class.forName( driver ).newInstance();
      System.out.println( "OK" );

      /* Test the connection */

      String url = "jdbc:mysql://localhost:3306/test";
        String username = "epuser";
      String password = "eppass";
      System.out.println( "\n=> connecting:" );
      DriverManager.getConnection( url, username, password );
      System.out.println( "OK" );
    }
    catch( Exception x ) {
      System.err.println( x );
    }
  }
}
Avatar of ramazanyich
ramazanyich
Flag of Belgium image

connect to mysql usign your mysql client and execute following line:
use mysql;
update user set host='%' where host='localhost' and user='epuser';
commit;
forgot to say: you should connect as mysql admin user.
ASKER CERTIFIED SOLUTION
Avatar of raj3060
raj3060
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If that one does not work then try this;
String username = "epuser";
String password = "eppass";
   String url = "jdbc:mysql://localhost/test?user="
                   + username
                   + "&password="
                   + password;
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url);
--Raj