Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLState: 28000

 
Chris-Huisman
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Further, you may have to grant access privileges to your user name.
Check it here
HTH
--
Venkat
 
Chris-Huisman
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help, but the problem was solved by granting all privileges to chris@localhost.localdomain.
c.
 
bitsurs bitsurs
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic