커넥터 8.0.11을 사용하여 MySql 데이터베이스를 Java와 연결하려고합니다. 모든 것이 정상인 것 같지만이 예외가 있습니다.
스레드 "main"java.sql.SQLNonTransientConnectionException의 예외 : 공개 키 검색이 허용되지 않습니다.
스택 추적 :
Exception in thread "main" java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:108) 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.(ConnectionImpl.java:444) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226) at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:438) at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:146) at com.mysql.cj.jdbc.MysqlDataSource.getConnection(MysqlDataSource.java:119) at ConnectionManager.getConnection(ConnectionManager.java:28) at Main.main(Main.java:8)
커넥터 관리자 :
public class ConnectionManager {
public static final String serverTimeZone = "UTC";
public static final String serverName = "localhost";
public static final String databaseName ="biblioteka";
public static final int portNumber = 3306;
public static final String user = "anyroot";
public static final String password = "anyroot";
public static Connection getConnection() throws SQLException {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setUseSSL( false );
dataSource.setServerTimezone( serverTimeZone );
dataSource.setServerName( serverName );
dataSource.setDatabaseName( databaseName );
dataSource.setPortNumber( portNumber );
dataSource.setUser( user );
dataSource.setPassword( password );
return dataSource.getConnection();
}
}