반응형

H2 DB 연동 중에 다음과 같은 오류가 발생했다.

 

그림1. H2 Console 설정

H2 콘솔 설정은 다음과 같이 연결 후에

 

인텔리제이에서 아래와 같이 테스트 코드를 작성 하고 돌리면

 

다음과 같은 오류가 발생하였다.

오류 내용 : org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database may be already in use

 

해결 방법 : 

H2 콘솔 페이지에서 연결을 해제하고 하면 오류가 발생하지 않았다. 하지만 H2 콘솔과 인텔리제이에서 동시에 접속이 가능해야 했기때문에 방법을 찾아보았고, 해결 방법은 다음과 같았다.

 

application.properties

spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
#spring.datasource.url=jdbc:h2:~/Db명 # 수정 전
spring.datasource.url=jdbc:h2:tcp://localhost/~/Db명 # 수정 후
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=

H2 콘솔 접속 페이지

반응형

+ Recent posts