H2를 실행시키면 cmd창과 H2 콘솔창이 뜬다.
- 이 때 주의할 점! cmd창을 닫게 되면 H2 접속 불가
JDBC URL에 DB 명을 지정해 주자
- jdbc:h2:tcp://localhost/~/{DB 명}
⛔ 아래와 같은 오류가 발생한다면?
Database "C:/Users/..." not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149 (도움말)
IntelliJ의 왼쪽, Database탭에서 Data Source 중 H2 선택하기
User는 sa로,
H2 콘솔에서 정한 DB 명을 Database에 작성하면 자동으로 URL에 반영된다.
spring:
datasource:
url: jdbc:h2:tcp://localhost/~/{DB 명}
username: sa
password:
driver-class-name: org.h2.Driver
runtimeOnly 'com.h2database:h2'