Access denied for user 'root'@'localhost' (using password: YES) in eclipse when connecting with jdbc

50 views Asked by At

I'am trying to access sql database from eclipse Java IDE using jdbc connectivity. But I'am encountering with a error "Error: Access denied for user 'root'@'localhost' (using password: YES)". Please help me.

package language;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBconnection {
    private static String url="jdbc:mysql://localhost:3306/language";
    private static String userName="root";
    private static String passWord="rootuser";
    


    public  static Connection getConnection() throws Exception{
        // TODO Auto-generated method stub
        return DriverManager.getConnection(url,userName,passWord);
    }

}

enter image description here See the error image!

SELECT Host,User,plugin,authentication_string FROM mysql.user;

+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| Host      | User             | plugin                | authentication_string                                                  |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
| localhost | chinnu           | mysql_native_password | *88FBBBF3EA3E4189FF5764256AC3B39A15CB2328                              |
| localhost | mysql.infoschema | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.session    | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys        | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | newuser          | mysql_native_password | *F071E3EB4C99F6E1F1CDD5E1031193757E974214                              |
| localhost | root             | mysql_native_password | *992C4DB09F487A275976576CCFA554F7D20A4207                              |
+-----------+------------------+-----------------------+------------------------------------------------------------------------+
0

There are 0 answers