JDBC 로 MySQL 연동 시, 다음과 같은 메세지가 출력되는 경우가 있습니다.
WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
위 메세지는 에러는 아니지만, 출력되는게 껄끄러우므로 URL 옵션에 useSSL=false 옵션을 부여하여 출력하지 않을 수 있습니다.
JDBC useSSL=false 옵션이 없는경우
import java.sql.*; import javax.sql.*; public class Main { protected static final String MYSQL_DRIVER_CLASS = "com.mysql.jdbc.Driver"; protected static final String URL_BASIC = "jdbc:mysql://192.168.0.136:3306/mysql"; public static Connection createConnectionByDriverManager(String id, String password) throws SQLException { try { Class.forName(MYSQL_DRIVER_CLASS); } catch (ClassNotFoundException sException) { } return DriverManager.getConnection(URL_BASIC, id, password); } public static void main(String[] args) throws Exception { Connection con = createConnectionByDriverManager("TEST", "test"); System.out.println("Connection Success"); con.close(); } }
$ java Main Wed Jul 04 23:44:36 KST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. Connection Success
JDBC useSSL=false 옵션이 있는 경우
import java.sql.*; import javax.sql.*; public class Main { protected static final String MYSQL_DRIVER_CLASS = "com.mysql.jdbc.Driver"; protected static final String URL_BASIC = "jdbc:mysql://192.168.0.136:3306/mysql?useSSL=false"; public static Connection createConnectionByDriverManager(String id, String password) throws SQLException { try { Class.forName(MYSQL_DRIVER_CLASS); } catch (ClassNotFoundException sException) { } return DriverManager.getConnection(URL_BASIC, id, password); } public static void main(String[] args) throws Exception { Connection con = createConnectionByDriverManager("TEST", "test"); System.out.println("Connection Success"); con.close(); } }
$ java Main Connection Success
'Database > MySQL' 카테고리의 다른 글
[MySQL] 소켓 번호 변경하기 (0) | 2018.10.08 |
---|---|
[MySQL] NL, Sort Merge, Hash Join 최적의 결합 방법 선택하기 (1) | 2018.08.17 |
[MySQL] MySQL 서버에 JDBC 로 연동하기 (0) | 2018.07.03 |
[MySQL] 데이터베이스 테이블 및 데이터 추출 적재하기 (0) | 2018.06.14 |
[MySQL] SHOW 로 볼 수 있는 목록 알아보기 (0) | 2018.06.13 |