Step 0. 상황
아래와 같이 데이터베이스 정보를 설정했는데 jdbc communication 예외가 발생했다.
spring:
datasource:
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://[HOST]:[PORT]/[데이터베이스명]
username: [USERNAME]
password: [PASSWORD]
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Step 1. 원인
MySQL의 SSL 설정이 true로 되어있기 때문에 유효하지 않은 패킷이라고 인식된 것이다. 워크벤치에서도 SSL 설정 값이 Require으로 설정되어있다면 아마 연결할 수 없었을 것이다. 기본으로 설정된 값은 If available이다.
Step 2. 해결
아래처럼 URL에 useSSL 설정값을 false로 설정한다.
url: jdbc:log4jdbc:mysql://[HOST]:[PORT]/[데이터베이스명]?useSSL=false
참고
[문제해결] the last packet sent successfully to the server was 0 milliseconds ago
'DB' 카테고리의 다른 글
[MyBatis] selectKey로 다중 컬럼 값 가져오기 (0) | 2023.05.30 |
---|---|
[MyBatis] BindingException 해결 (feat. IntelliJ Gradle 설정) (1) | 2023.05.29 |
[MySQL] SQL state [HY000]; error code [1366]; Incorrect string value (0) | 2023.03.31 |
[MyBatis] MyBatis 설정과 log4jdbc-log4j2 적용기 (0) | 2023.03.31 |
[DB] JOIN 알고리즘과 성능에 대하여 (0) | 2023.03.15 |