Notice
Recent Posts
Recent Comments
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Archives
Today
In Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

A Joyful AI Research Journey๐ŸŒณ๐Ÿ˜Š

H2: ์„ค์น˜ํ•˜๊ณ  ์‹คํ–‰ํ•ด๋ณด๊ธฐ ๋ณธ๋ฌธ

๐Ÿ’ปBootcamp Self-Study Revisionโœจ/Spring, Spring Boot, Java, SQL

H2: ์„ค์น˜ํ•˜๊ณ  ์‹คํ–‰ํ•ด๋ณด๊ธฐ

yjyuwisely 2023. 4. 10. 14:12

230410 Mon

application.properties

spring.datasource.url=jdbc:h2:~/test

์œ„ ์ฝ”๋“œ์˜ ๊ฒฝ์šฐ D:\์— test ํด๋”๋ฅผ ๋งŒ๋“ค๊ณ  ๊ทธ ์•ˆ์— h2 ํŒŒ์ผ์„ ๋„ฃ์œผ๋ฉด ๋œ๋‹ค.

# DATABASE
# H2 ์ฝ˜์†”์˜ ์ ‘์†์„ ํ—ˆ์šฉํ• ์ง€์˜ ์—ฌ๋ถ€์ด๋‹ค. true๋กœ ์„ค์ •ํ•œ๋‹ค.
spring.h2.console.enabled=true
# ์ฝ˜์†” ์ ‘์†์„ ์œ„ํ•œ URL ๊ฒฝ๋กœ์ด๋‹ค.
spring.h2.console.path=/h2-console

# ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ ‘์†์„ ์œ„ํ•œ ๊ฒฝ๋กœ์ด๋‹ค.
# ์„ค์ •ํ•œ ๊ฒฝ๋กœ์— ํ•ด๋‹นํ•˜๋Š” ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์•ผ ํ•œ๋‹ค. 
spring.datasource.url=jdbc:h2:~/test

# ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ ‘์†์‹œ ์‚ฌ์šฉํ•˜๋Š” ๋“œ๋ผ์ด๋ฒ„์ด๋‹ค.
spring.datasource.driverClassName=org.h2.Driver
# ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ์‚ฌ์šฉ์ž๋ช…์ด๋‹ค. (์‚ฌ์šฉ์ž๋ช…์€ ๊ธฐ๋ณธ ๊ฐ’์ธ sa๋กœ ์„ค์ •ํ•œ๋‹ค.)
spring.datasource.username=sa
# ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ํŒจ์Šค์›Œ๋“œ์ด๋‹ค. ๋กœ์ปฌ ๊ฐœ๋ฐœ ์šฉ๋„๋กœ๋งŒ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํŒจ์Šค์›Œ๋“œ๋ฅผ ์„ค์ •ํ•˜์ง€ ์•Š์•˜๋‹ค.
spring.datasource.password=

C:\DEV์— ๋‹ค์šด๋ฐ›๋Š”๋‹ค. 
C:\DEV\h2\bin

์— ์žˆ๋Š” h2w.bat ํŒŒ์ผ ์‹คํ–‰ํ•œ๋‹ค.


Database "C:/Users/์‚ฌ์šฉ์ž์ด๋ฆ„/jblog"

๋Š” ์ž…๋ ฅ์ฐฝ์˜ jdbc:h2:~/jblog ์™€ ๊ฐ™๋‹ค.


๊ฒฐ๊ณผ) ์—ฐ๊ฒฐ์ด ๋๋‹ค.

์ฐธ๊ณ : https://wikidocs.net/161164


SQL์„ ์ž‘์„ฑํ•œ๋‹ค.

CREATE TABLE USERS (
ID NUMBER(5) PRIMARY KEY,
USERNAME VARCHAR2(30),
PASSWORD VARCHAR2(100),
EMAIL VARCHAR2(30)
);
INSERT INTO USERS(ID, USERNAME, PASSWORD, EMAIL) VALUES(1, 'guest', 'guest123', 'guest@gmail.com');

USERS ํ…Œ์ด๋ธ” ๊ฒ€์ƒ‰ํ•ด๋ณธ๋‹ค.

๊ฒฐ๊ณผ) ํ…Œ์ด๋ธ”๊ณผ ๋ฐ์ดํ„ฐ๊ฐ€ ๋‚˜์˜จ๋‹ค.


728x90
๋ฐ˜์‘ํ˜•
Comments