끄적끄적 코딩일지

[Spring]이미지 월드컵 만들기(2) - Database 연결 본문

Project/[Spring] 이미지 월드컵 만들기

[Spring]이미지 월드컵 만들기(2) - Database 연결

BaekGyuHyeon 2022. 5. 18. 10:31

지난 시간에 이미지 월드컵을 만들기 위한 Spring프로젝트를 생성해 봤다.

2022.05.18 - [Project/[Spring] 이미지 월드컵 만들기] - [Spring boot]이미지 월드컵 만들기(1) - 프로젝트 세팅

 

[Spring boot]이미지 월드컵 만들기(1) - 프로젝트 세팅

Spring을 사용한 어떤 프로젝트를 고민이 들던때쯤 자기전의 국롤인 유튜브 영상을 보다가 이미지 월드컵을 하는 유튜버를 보면서 저거정도는 쉽게 만들어 볼수 있겠다!! 라는 생각이 들었다. 당

blablacoding.tistory.com

사용할 Database는 고민끝에 가장 익숙한 Postgresql을 사용하기로 결정

 

build.gradle에 jdbc postgres driver 라이브러리를 추가하자

 

그리고 application.properties 수정

 

spring.datasource.url -> 연결할 database 주소

spring.datasource.username -> database에 로그인할 user, postgresql기준 기본값 postgres

spring.datasource.password -> database 설치시 혹은 user 생성시 설정한 비밀번호

spring.jpa.hibernate.ddl-auto -> 테이블 생성 전략

 spring.datasource.driver-class-name -> database와 연결할 driver

 

그리고 한번 실행시켜 database 연결 테스트를 해보는데...

 

잉...??

왜 에러가 나지?

오류내용은

org.postgresql.util.PSQLException: The authentication type 10 is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or subnet, and that it is using an authentication scheme supported by the driver.

 

postgresql에서는 외부접속을 허용하기 위해 pg_hba.conf 파일과 postgresql.conf 파일을 수정해야 한다.

그런데 local으로 접속하는데 왜 저런 오류가 뜨는거지???

혹시몰라 해당 파일을 확인해 보는데 예전에 외부접속이 가능하도록 이미 수정해둔 파일...

구글링을 해보니

 

https://starlikebn.tistory.com/entry/%EC%9E%90%EB%B0%94-Postgre-%EC%97%B0%EB%8F%99%EC%8B%9C-%EC%98%A4%EB%A5%98-The-authentication-type-10

 

자바 Postgre 연동시 오류 The authentication type 10

멍청이 같지만... org.postgresql.util.PSQLException: The authentication type 10 is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or subnet, and..

starlikebn.tistory.com

 

Postgres driver 버전 문제란다.

build.gradle으로 돌아가서 postgres jdbc driver 버전 수정

https://mvnrepository.com/artifact/org.postgresql/postgresql

 

Maven Repository: org.postgresql » postgresql

PostgreSQL JDBC Driver Postgresql

mvnrepository.com

그리고 실행해 보니 아주 잘 돌아간다 ㅎㅎ

다음 글에서는 Entity를 설계해 보겠다.