2 messages in com.mysql.lists.javaRE: java.sql.SQLException: Invalid au...| From | Sent On | Attachments |
|---|---|---|
| Yousef Bahadori | 19 Aug 2002 19:53 | |
| priyank | 19 Aug 2002 21:31 |
| Subject: | RE: java.sql.SQLException: Invalid authorization specification: Access denied![]() |
|---|---|
| From: | priyank (priy...@intersolutions.stpn.soft.net) |
| Date: | 08/19/2002 09:31:24 PM |
| List: | com.mysql.lists.java |
Hi Yousef,
I think you need to check up the URL format. You need to use the following format:
To connect to the database, you need to use a JDBC url with the following format ([xxx] denotes optional url components):
jdbc:mysql://[hostname][:port]/[dbname][?param1=value1][¶m2=value2].....
This is described in the Driver documentation. Accordingly, the piece of code you must use is:
try { Class.forName("org.gjt.mm.mysql.Driver").newInstance(); } catch (ClassNotFoundException cnfe) { System.err.println("Error loading driver: "+cnfe); }
Connection con = DriverManager.getConnection ("jdbc:mysql://localhost/Authority?user=root&password=fox123");
}
thanks
-----Original Message----- From: Yousef Bahadori [mailto:sbah...@houston.rr.com] Sent: Tuesday, August 20, 2002 8:24 AM To: ja...@lists.mysql.com Subject: java.sql.SQLException: Invalid authorization specification: Access denied
Hi:
I am new to the usage of mysql with java. I have the following problem when I am trying connect to the server from java. My code looks like the following: try { Class.forName("org.gjt.mm.mysql.Driver").newInstance(); } catch (ClassNotFoundException cnfe) { System.err.println("Error loading driver: "+cnfe); }
Connection con = DriverManager.getConnection ( "jdbc:mysql://localhost/Authority","root","fox123");
}
/*
the following works connecting to the test database without passing parameter. Connection con = DriverManager.getConnection ( "jdbc:mysql://localhost/test"); */
When I run the above code I get the following message: java.sql.SQLException: Invalid authorization specification: Access denied for user: 'root@localhost.localdomain' (Using password: YES) at com.mysql.jdbc.MysqlIO.init(Unknown Source) at com.mysql.jdbc.Connection.connectionInit(Unknown Source) at com.mysql.jdbc.jdbc2.Connection.connectionInit(Unknown Source) at com.mysql.jdbc.Driver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at mysql_class.main(mysql_class.java:18)
However, I am able to connect to my server on command line with the user='root' and password='fox123'; I checked the user table on mysql database and ran the following command: select host,user,password from user where user='root'; +-----------------------+------+------------------+ | host | user | password | +-----------------------+------+------------------+ | localhost | root | 122a83cd749df649 | | localhost.localdomain | root | 122a83cd749df649 | +-----------------------+------+------------------+ 2 rows in set (0.00 sec)
I use the following jar file: mm.mysql-2.0.4-bin.jar
I'll appreciate very much if anybody could shed some light on this problem.
thanx,
--------------------------------------------------------------------- Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before posting. To request this thread, e-mail java...@lists.mysql.com
To unsubscribe, send a message to the address shown in the List-Unsubscribe header of this message. If you cannot see it, e-mail java...@lists.mysql.com instead.




