File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes SQLState: 28000 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQLState: 28000" Watch "SQLState: 28000" New topic

SQLState: 28000


Joined: Jan 25, 2002
Posts: 23
I am having a problem connecting to a mysql database.
My url string is as follows:
private static final String url = "jdbc:mysql://localhost:3306/therezworks";
and I call the DriverManager with:
DriverManager.getConnection(url, userName, password);
The output of this is:
Error message: Invalid authorization specification: Access denied for user: 'chris@localhost.localdomain' (Using password: YES)
SQLState: 28000
Vendor: 1045

any ideas???
Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
Hi Chris,
U can find this URL of some help

Sita Kodali
Ranch Hand

Joined: Dec 02, 2001
Posts: 72
Further, you may have to grant access privileges to your user name.
Check it here

Joined: Jan 25, 2002
Posts: 23
I have done a:
GRANT ALL PRIVILEGES ON therezworks.* TO chris@localhost IDENTIFIED BY 'some_pass'
but I still see the error.
I don't understand what I'm doing wrong. I am able to connect to mysql using:
mysql -u chris -p
and access all of the tables in my database, but I am not given access when attempting to get to them via a servlet.

Joined: Jan 25, 2002
Posts: 23
Thanks for the help, but the problem was solved by granting all privileges to chris@localhost.localdomain.
bitsurs bitsurs

Joined: Sep 21, 2005
Posts: 1
That's was very helpful!!

Your MySQL user must have a password assigned. The driver will fail if you try to connect with an empty password.

The Apache Jakarta Tomcat 5 Servlet/JSP Container

MySQL Connector/J must use TCP/IP sockets to connect to MySQL, as Java does not support Unix Domain Sockets. Therefore, when MySQL Connector/J connects to MySQL, the security manager in MySQL server will use its grant tables to determine whether or not the connection should be allowed.

You must add grants to allow this to happen. The following is an example of how to do this (but not the most secure).

From the mysql command-line client, logged in as a user that can grant privileges, issue the following command:

'[user]'@'[hostname]' identified by

replacing [dbname] with the name of your database, [user] with the user name, [hostname] with the host that MySQL Connector/J will be connecting from, and [password] with the password you want to use. Be aware that RedHat Linux is broken with respect to the hostname portion for the case when you are connecting from localhost. You need to use "localhost.localdomain" for the [hostname] value in this case.
Follow this by issuing the "FLUSH PRIVILEGES" command.

MySQL Manual: Common Problems and Solutions
I agree. Here's the link:
subject: SQLState: 28000
It's not a secret anymore!