0

I'm getting permission denied error:

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO).

I do not know why.

This is my code:

try{
    Class.forName("com.mysql.jdbc.Driver");
   
    con1=DriverManager.getConnection("jdbc:mysql://localhost/schoolmanagementdb","root","");   
    insert=con1.prepareStatement("insert into schoolmanagementtbl(name,mobile,course)values(?,?,?)");
    insert.setString(1,name);
    insert.setString(2,mobile);
    insert.setString(3,course);
    insert.executeUpdate();

    JOptionPane.showMessageDialog(this,"Record Addeddd");
}
catch(ClassNotFoundException ex){
    Logger.getLogger(form1.class.getName()).log(Level.SEVERE,null,ex);
}
catch(SQLException ex){
    Logger.getLogger(form1.class.getName()).log(Level.SEVERE,null,ex);
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Is this the database you own? And is there indeed no password? – Vitaly Chura Oct 15 '22 at 14:06
  • PHPMyAdmin is not involved here, that is just a PHP-based query tool for MySQL. You are probably specifying the wrong username and/or password (e.g. your password is empty, which is unlikely to be the case). – Mark Rotteveel Oct 15 '22 at 16:13

0 Answers0