Solved

java.sql.SQLException: Invalid authorization specification

Posted on 2004-08-31
4
3,451 Views
Last Modified: 2008-01-09
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 );
    }
  }
}
0
Comment
Question by:jeff1919
  • 2
  • 2
4 Comments
 
LVL 19

Expert Comment

by:ramazanyich
ID: 11949927
connect to mysql usign your mysql client and execute following line:
use mysql;
update user set host='%' where host='localhost' and user='epuser';
commit;
0
 
LVL 19

Expert Comment

by:ramazanyich
ID: 11949930
forgot to say: you should connect as mysql admin user.
0
 
LVL 11

Accepted Solution

by:
raj3060 earned 250 total points
ID: 11952502
You problem is at URL. Give host id i.e. IP address of localhost. it should look like this.
String url = "jdbc:mysql://172.10.25.35:3306/test";
See if it works.
--Raj
0
 
LVL 11

Expert Comment

by:raj3060
ID: 11952551
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
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now