목차
반응형
H2 database 설치
https://www.h2database.com
권한 주기:
chmod 755 h2.sh
실행:
./h2.sh
데이터베이스 파일 생성 방법
jdbc:h2:~/test
(최초 한번)~/test.mv.db
파일 생성 확인- 이후부터는
jdbc:h2:tcp://localhost/~/test
이렇게 접속
테이블 생성하기
테이블 관리를 위해 프로젝트 루트에 sql/ddl.sql
파일을 생성
drop table if exists member CASCADE;
create table member (
id bigint generated by default as identity,
name varchar(255),
primary key (id)
);
환경설정build.gradle
파일에 jdbc, h2
데이터베이스 관련 라이브러리 추가
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
runtimeOnly 'com.h2database:h2'
스프링 부트 데이터베이스 연결 설정 추가resources/application.properties
spring.datasource.url=jdbc:h2:tcp://localhost/~/test
spring.datasource.driver-class-name=org.h2.Driver
반응형
반응형
H2 database 설치
https://www.h2database.com
권한 주기:
chmod 755 h2.sh
실행:
./h2.sh
데이터베이스 파일 생성 방법
jdbc:h2:~/test
(최초 한번)~/test.mv.db
파일 생성 확인- 이후부터는
jdbc:h2:tcp://localhost/~/test
이렇게 접속
테이블 생성하기
테이블 관리를 위해 프로젝트 루트에 sql/ddl.sql
파일을 생성
drop table if exists member CASCADE;
create table member (
id bigint generated by default as identity,
name varchar(255),
primary key (id)
);
환경설정build.gradle
파일에 jdbc, h2
데이터베이스 관련 라이브러리 추가
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
runtimeOnly 'com.h2database:h2'
스프링 부트 데이터베이스 연결 설정 추가resources/application.properties
spring.datasource.url=jdbc:h2:tcp://localhost/~/test
spring.datasource.driver-class-name=org.h2.Driver
반응형