[Spring] Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection, 데이터베이스 접속 에러

Amazon RDS and Amazon Aurora SSL/TLS 인증서를 업데이트 후 별다른 설정 변경을 하지 않았지만, 오랜만에 빌드하는 스프링부트 프로젝트의 데이터베이스 연결이 되지 않는 현상 발생하였다. [### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host “{host}”, user “{user}”, database “{database}”, no encryption ] RDS 인증서 업데이트 작업 후 SSL 요구설정이 활성화된 것으로, 해당 에러가 나며 접속이 안된다면 다음과 같이 조치할 수 있다. ...

July 25, 2024 · Jun Kang

[Spring] 스프링부트 + Mybatis 데이터소스 여러개 연결 (스프링 다중 데이터베이스 연결)

다음은 스프링부트 + 마이바티스 프로젝트에 2개 이상의 데이터소스를 연결하는 예제이다. 기존 스프링 데이터베이스 연동이 되어있다고 가정 후 진행되며, 신규 데이터베이스는 구별이 쉽도록 new 데이터베이스로 명칭 한다. 1. 신규 데이터베이스 접속정보 추가 추가될 데이터베이스의 속성을 application.properties에 추가 #기존 DB Setting spring.datasource.url={url} spring.datasource.driverClassName={driverClassName} spring.datasource.username={username} spring.datasource.password={password} spring.datasource.schema={schema} #추가될 DB Setting new.datasource.url={url} new.datasource.driverClassName={driverClassName} new.datasource.username={username} new.datasource.password={password} new.datasource.schema={schema} 2. 데이터베이스 연결 빈 속성 추가 기존 데이터베이스 연결 설정을 하는 DatabaseConfig.java 외에 NewDatabaseConfig.java신규로 추가한다. 기존 DatabaseConfig.java ...

October 20, 2023 · Jun Kang