I am trying to connect to MySQL database and fetch some data using sql statement in my java code. but i cant connect to my database with the following SQL Exception.
ERROR: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
my java code is as bellow:
Mysql_connecter.java
package mysql_connecter;
import java.sql.*;
/**
 *
 * @author kass
 */
public class Mysql_connecter 
{
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) 
    {
        try
        {
            Class.forName("com.mysql.jdbc.Driver");
            System.out.println("connecting.....");
            try (Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","user","password")) 
            {
                System.out.println("connected to mysql DB");
                Statement stmt=con.createStatement();
                ResultSet rs=stmt.executeQuery("select * from my_table");
                while(rs.next())
                {
                    System.out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3));
                }
            }
            catch(SQLException e)
            { 
                System.out.println("ERROR: ["+e+"]");
            }
        }
        catch(ClassNotFoundException e)
        { 
            System.out.println(e);
        }
    } 
}
i have added the mysql jdbc driver to my library path. can some one point me i miss something in my code?
 
     
    