This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JDBC and the fly likes Access denied to me in mysql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Access denied to me in mysql" Watch "Access denied to me in mysql" New topic
Author

Access denied to me in mysql

Trelston Moraes
Greenhorn

Joined: Feb 27, 2008
Posts: 10
I have used the following piece of code to connect to a MySql database.The error message that i get is "Access denied for user 'ROOT'@'TRELSTON' (using password: YES)". Please check the code and see if it is perfect or i have made a mistake somewhere or this error is because i have no access to the database. My PM thinks i have made a mistake.
Please help.


<%

String dbUrl ="jdbc:mysql://dest:3306/ai?user=ROOT&password=root";
String dbClass = "com.mysql.jdbc.Driver";
//String query = "Select * FROM users";
Connection con = null;
try {

Class.forName(dbClass).newInstance();
//con = DriverManager.getConnection("jdbc:mysql://destscience:3306/Sakai","ROOT","sa");
con = DriverManager.getConnection(dbUrl);
//Statement stmt = con.createStatement();
out.print("Connection Created");
con.close();
}
catch(Exception e)
{
out.print(e.getMessage());
}
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

Trelston,
Welcome to JavaRanch!

Can you connect to mysql from the command line with that username/password? This will help narrow down where the problem lies.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Trelston Moraes
Greenhorn

Joined: Feb 27, 2008
Posts: 10
Originally posted by Jeanne Boyarsky:
Trelston,
Welcome to JavaRanch!

Can you connect to mysql from the command line with that username/password? This will help narrow down where the problem lies.


Thanks Jeanne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access denied to me in mysql
 
Similar Threads
whats wrong here in connection string
how to connect MySql
Errow when connecting JSP to MySQL
ClassNotFoundException out of nowhere!!
Properties file for DB connection