Solved

java.sql.SQLException: Invalid authorization specification

Posted on 2004-08-31
4
3,557 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jquery to restrict certain words from input in form 11 39
Redirect Website for Mobile Devises 9 133
Scientific articles behind a login? 6 32
Wordpress Security 29 48
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

860 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