본문 바로가기

오류 해결 방법

[web] db 연결 오류 - jdbc.exceptions.CommunicationsException (db없음)

문제 요약

Spring Boot 프로젝트를 실행했지만 localhost:8080 접속이 되지 않았고, DB 연결이 되지 않음.
DB 연결 설정은 정확했으며, RDS 퍼블릭 액세스, 보안 그룹, 비밀번호 등도 문제없었음.


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.


java.sql.SQLSyntaxErrorException: Unknown database 'db이름'

 

원인

Spring Boot 설정에서 사용한 DB 이름이 실제로 RDS에 존재하지 않았음.

  • application.properties  설정에 따라 elephantdiarydb2라는 DB가 RDS 인스턴스에 있어야 했는데, 실제로는 존재하지 않았음.
  • RDS는 DB가 존재하지 않으면 Spring Boot 애플리케이션이 실행되지 않고 connection refused 또는 access denied 오류 발생

해결 방법

DBeaver에서 다음 쿼리 실행:

  • 새로 만든 후 Spring Boot 재실행 → 정상 작동함
  • F5 또는 Refresh로 데이터베이스 트리 갱신해서 존재 여부 확인함