MySQL 8 JDBC exception

609 Views Asked by At

//I just use the example database for my java test, I used 5.0 before after change connector 8.0 the same code don't work. I tried to solve the 'S S L', I think it's not enough.

public class test{
    public static final String DBDRIVER = "com.mysql.cj.jdbc.Driver" ;
        public static final String DBURL = "jdbc:mysql://127.0.0.1:3306/world?characterEncoding=utf8&useSSL=true&verifyServerCertificate=false" ;
    public static final String DBUSER = "root" ;
    public static final String DBPASS = "password" ;

//================================================================================================

C:\Users\Administrator\Documents\test>java test
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:127)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
        at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
        at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862)
        at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444)
        at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)
        at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at test.main(test.java:21)
null
Exception in thread "main" java.lang.NullPointerException
        at test.main(test.java:28)
0

There are 0 best solutions below