Burninghering's Blog
article thumbnail
Published 2022. 10. 27. 23:56
H2 접속 오류 궁금해요

application.properties에

spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:testdb

이렇게 설정하고,

http://localhost:8080/h2-console 접속

 

첫 번째 발생한 오류

C:/Users/사용자명/test" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149

해결법) 

로그인 화면의 jdbc url에 아래의 값

jdbc:h2:뒤에 Database not found라고 나온 경로를 넣어주고 연결 버튼을 누른다.

jdbc:h2:/Users/사용자명/test
 

H2 에러 (Database "/Users/juhyeontae/test" not found, either pre-create it or allow remote database creation (not recommended

JPA테스트를 위한 목적으로 h2를 설치하고 h2를 실행하려고 하니 아래처럼 뭔가 에러메시지와함께, h2로그인이 안되는 현상이 있었다.. 뭔지.. ? Database "/Users/juhyeontae/test" not found, either pre-creat..

honeyinfo7.tistory.com

 

test.mv.db라는 파일이 없어서 위와 같은 에러가 난 것이라고 한다.

 

그런데..

두 번째 발생한 오류

Wrong user name or password [28000-214] 28000/28000 (Help)

 

블로그들을 찾아보니,

Spring boot 2.4버전 이후부터는

spring.datasource.username=sa

을 properties에 추가해줘야 한다고 한다.

 

근데 추가해도 로그인이 안된다.

그래서 

User Name을 없애고 Connect를 시도했더니

접속 완료...

 

내가 마지막으로 설정한 properties는 다음과 같다.

spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driver-class-name=org.h2.Driver

2022/10/30 추가

 

위와 같은 방법으로는

스프링에서 만든 테이블과 연결이 되지 않는다는 것을 알았다.

 

아래와 같이 properties를 설정해주고,

spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:testdb

 

H2에 접속할 때에 아래와 같이 URL을 변경해준다.

 

 

접속 완료 및 java 클래스가 테이블로 인식되게 함

profile

Burninghering's Blog

@개발자 김혜린

안녕하세요! 반갑습니다.