0
     import java.lang.*;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.SQLException;
    public class tentar {
        public static void main(String[] args) {
            Connection con=null;
        try {
            new com.mysql.jdbc.Driver();
        }
        catch(SQLException exSQL) {
            System.out.println("Errore connessione DB 23 "+exSQL.getErrorCode()+exSQL.getSQLState()+exSQL.getMessage());
        }

        try {
            con=DriverManager.getConnection("jdbc:mysql://localhost:3306/dataJ", "root","password");
        }
        catch(SQLException exSQL) {
            System.out.println("Errore connessione DB "+ exSQL.getErrorCode());
            System.out.println(exSQL.getSQLState() + exSQL.getMessage());
            exSQL.printStackTrace();
        }
        finally {
            try {
            con.close();
            }
            catch(SQLException exSQL) {
                System.out.println("Errore connessione DB "+ exSQL.getErrorCode());
                System.out.println(exSQL.getSQLState() + exSQL.getMessage());
                exSQL.printStackTrace();
            }
        }

当我启动代码时引发异常SQL:MySQLNonTransientConnectionException

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.Util.getInstance(Util.java:381)
08004Client does not support authentication protocol requested by server; consider upgrading MySQL client

我正在使用 Eclipse,并且我已经包含了 mysql-connector-java 5.1.7。MySQL 版本 8.0.18 和 Java 1.8.0_231。我哪里错了?

4

0 回答 0