//我只是使用示例数据库进行java测试,我使用了5.0前后更改连接器8.0相同的代码不起作用。我试着解决“s l”,我觉得这还不够。
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)
暂无答案!
目前还没有任何答案,快来回答吧!