This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQLState: 28000 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLState: 28000" Watch "SQLState: 28000" New topic
Author

SQLState: 28000

Chris-Huisman
Greenhorn

Joined: Jan 25, 2002
Posts: 23
Hello,
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:
------SQLException------
Error message: Invalid authorization specification: Access denied for user: 'chris@localhost.localdomain' (Using password: YES)
SQLState: 28000
Vendor: 1045

any ideas???
Thanks,
chris.
Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
Hi Chris,
U can find this URL of some help
http://p2p.wrox.com/archive/java_databases/2001-11/0.asp

Mahesh
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
HTH
--
Venkat
Chris-Huisman
Greenhorn

Joined: Jan 25, 2002
Posts: 23
Hi,
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.
c.
Chris-Huisman
Greenhorn

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

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

1:
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

2:
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:

GRANT ALL PRIVILEGES ON [dbname].* to
'[user]'@'[hostname]' identified by
'[password]'

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: http://aspose.com/file-tools
 
subject: SQLState: 28000