Spring

[Spring] Spring Boot H2 Database Console 사용하기

📝 작성 : 2020.06.21  ⏱ 수정 : 
728x90

H2 Database

H2 Database는 자바로 작성된 관계형 데이터베이스 관리 시스템(RDBMS)입니다.

공식 홈페이지에서 설명하는 H2 Database의 특징은 다음과 같습니다.

  • 매우 빠른 JDBC API 오픈 소스 (Very fast, open source, JDBC API)
  • 임베디드 및 서버 모드; 인 메모리 데이터베이스(Embedded and server modes; in-memory databases)
  • 브라우저 기반 콘솔 애플리케이션(Browser based Console application)
  • 작은 설치 공간 : 약 2MB의 jar 파일 크기(Small footprint: around 2 MB jar file size)
  • 트랜잭션 지원, 다중 버전 동시성(Transaction support, multi-version concurrency)

In-Memory Databases(IMDB)?

인메모리 데이터베이스는 디스크나 SSD에 데이터를 저장하는 데이터베이스와 달리 주로 데이터 저장을 위해 메모리에 의존하는 목적에 맞게 구축된 데이터베이스 유형입니다.

- 아마존 aws

 

 

H2 Database 설정

1. 의존 라이브러리 추가

Maven

<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <scope>runtime</scope>
</dependency>

Gradle

runtimeOnly 'com.h2database:h2'

 

2. 설정

application.properties 에 아래와 같이 입력합니다.

spring.datasource.driverClassName=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
spring.datasource.password=

spring.h2.console.enabled=true

 

3. 접속

http://localhost:포트번호/h2-console에 접속하면 로그인 화면이 나옵니다.

h2 console

 

Connect버튼을 클릭하여 접속합니다.

h2 console 접속

반응형