Search
Duplicate
โ›ณ

connection pooling

Connection ์ƒ์„ฑ

DriverManager

โ€ข
๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ๋ฐฉ๋ฒ•
โ€ข
JDBC 4.0 ๋ถ€ํ„ฐ DriverManager๊ฐ€ ์ ์ ˆํ•œ JDBC ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์ฐพ๋Š”๋‹ค.
โ€ข
์ปค๋„ฅ์…˜ ํ’€๋ง, ๋ถ„์‚ฐ ํŠธ๋žœ์žญ์…˜์„ ์ง€์›ํ•˜์ง€ ์•Š์Œ
DriverManager.getConnection(H2_URL)
Java
๋ณต์‚ฌ

DataSource

โ€ข
๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค, ํŒŒ์ผ ๊ฐ™์€ ๋ฌผ๋ฆฌ์  ๋ฐ์ดํ„ฐ ์†Œ์Šค์— ์—ฐ๊ฒฐํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค
โ€ข
์ปค๋„ฅ์…˜ ํ’€๋ง, ๋ถ„์‚ฐ ํŠธ๋žœ์žญ์…˜์„ ์ง€์›ํ•จ
JdbcDataSource dataSource = new JdbcDataSource(); dataSource.setURL(H2_URL);
Java
๋ณต์‚ฌ

Connection pooling

* DataSource๊ฐ์ฒด๋ฅผ ํ†ตํ•ด ๋ฏธ๋ฆฌ ์ปค๋„ฅ์…˜(Connection)์„ ๋งŒ๋“ค์–ด ๋‘๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•œ๋‹ค. *์ƒˆ๋กœ์šด ์ปค๋„ฅ์…˜์„ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ์€ ๋งŽ์€ ๋น„์šฉ์ด ๋“ค๊ธฐ์— ๋ฏธ๋ฆฌ ์ปค๋„ฅ์…˜์„ ๋งŒ๋“ค์–ด๋‘๋ฉด ์„ฑ๋Šฅ์ƒ ์ด์ ์ด ์žˆ๋‹ค. *์ปค๋„ฅ์…˜ ํ’€๋ง์— ๋ฏธ๋ฆฌ ๋งŒ๋“ค์–ด๋‘” ์ปค๋„ฅ์…˜์€ ์žฌ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๋‹ค. * * h2์—์„œ ์ œ๊ณตํ•˜๋Š”JdbcConnectionPool๋ฅผ ๋‹ค๋ค„๋ณด๋ฉฐ ์ปค๋„ฅ์…˜ ํ’€์— ๋Œ€ํ•œ ๊ฐ์„ ์žก์•„๋ณด์ž.
Plain Text
๋ณต์‚ฌ
JdbcConnectionPool jdbcConnectionPool = JdbcConnectionPool.create(H2_URL, USER, PASSWORD); try (Connection connection = jdbcConnectionPool.getConnection()) { }
Java
๋ณต์‚ฌ

Hikari CP

Spring Boot 2.0 ๋ถ€ํ„ฐ HikariCP๋ฅผ ๊ธฐ๋ณธ ๋ฐ์ดํ„ฐ ์†Œ์Šค๋กœ ์ฑ„ํƒ Hikari CP ํ•„์ˆ˜ ์„ค์ • - dataSourceClassName or jdbcUrl - username - password
Markdown
๋ณต์‚ฌ