This is an error for me. I have used proper password as this is what I type when I start MySQL.
DefaultTableModel dtm=(DefaultTableModel) jTable1.getModel();
dtm.setRowCount(0);
try{
Class.forName("java.sql.Driver");
Connection c=DriverManager.getConnection("jdbc:mysql://localhost/shashvat","root","1234");
Statement s=c.createStatement();
ResultSet r=s.executeQuery("select * from phasetests;");
while(r.next()){
Object arr[]={r.getString(1),r.getString(2),r.getString(3),r.getString(4)};
dtm.addRow(arr);
}
}catch(Exception e){
System.out.println(e.getMessage());
}
The Exception Message:
Access denied for user 'root'@'localhost' (using password: YES)
I have tried this too: https://stackoverflow.com/a/17908407/5036731
The problem still persists. Please help.