MySQLNonTransientConnectionException при подключении программы Java к моей базе данных в MySQL - PullRequest
0 голосов
/ 09 января 2020
     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. Где я не прав?

...