wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 30124
    
150

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
 
Consider Paul's rocket mass heater.
 
subject: Access denied to me in mysql
 
Similar Threads
Properties file for DB connection
ClassNotFoundException out of nowhere!!
whats wrong here in connection string
Errow when connecting JSP to MySQL
how to connect MySql