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();
            }
        }

When i start the code are raised the exceptionSQL: 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

I'm using Eclipse and i already include mysql-connector-java 5.1.7. MySQL version 8.0.18 and Java 1.8.0_231. Where am I wrong?

Stefan Drissen
  • 3,266
  • 1
  • 13
  • 21
  • Protocol you have requested is wrong, which means you are using mysql://localhost, but you have use mysq:http://localhost. – Salman Jan 09 '20 at 19:42
  • Currently, java is treating mysql: as protocol, there is no protocol exist of just type, that's why it's giving you error, it's clearly defined in the error. – Salman Jan 09 '20 at 19:43
  • Thank you so much! – Jormungand Jan 09 '20 at 20:42

0 Answers0