wood burning stoves
The moose likes JDBC and Relational Databases 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 The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31680
    
189

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.


[OCA 8 book] [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
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: Access denied to me in mysql