transaction

Isolation level

JoonHo Son
// java.sql.Connection์— ์ •์˜๋จ int TRANSACTION_NONE = 0; int TRANSACTION_READ_UNCOMMITTED = 1; int TRANSACTION_READ_COMMITTED = 2; int TRANSACTION_REPEATABLE_READ = 4; int TRANSACTION_SERIALIZABLE = 8; ์•„๋ž˜์˜ ๋‚ด์šฉ์€ ํ˜ธ๋ฐ•๊ณ ๊ตฌ๋ฉ”์˜ ๊ฒŒ์ž„ ์ด์•ผ๊ธฐ ์—์„œ ์ผ๋ถ€ ๋ฐœ์ทŒ. ๊ฐ ๋ ˆ๋ฒจ๋ณ„ ์ƒ์ˆ˜๋Š” ๋ฐœ์ทŒํ•œ ๋ธ”๋กœ๊ทธ์˜ ๋‚ด์šฉ์ด ์ž˜๋ชป๋˜์–ด ์‹ค์ œ java.sql.Connection ํด๋ž˜์Šค์— ์ •์˜๋œ ์ƒ์ˆ˜๋กœ ๋Œ€์ฒด(๋ถ‰์€๊ธ€์”จ ) ์ฐจ๋‹จ ๋ ˆ๋ฒจ ์ฐจ๋‹จ๋ ˆ๋ฒจ (Isolcation level) Dirty read Non-repeatable read Phantom read TRANSACTION_READ_UNCOMMIT O O O TRANSACTION_READ_COMMIT X O O TRANSACTION_REPEATABLE_READ X X O(X) TRANSACTION_SERIALIZABLE X X X Connection ์ธํ„ฐํŽ˜์ด์Šค์—์„œ ํŠธ๋žœ์žญ์…˜ ์ฐจ๋‹จ ๋ ˆ๋ฒจ๊ณผ ๊ด€๋ จ๋œ ํ•„๋“œ ํ•„๋“œ ์„ค๋ช… ๊ฐ’ int TRANSACTION_NONE ํŠธ๋žœ์žญ์…˜์ด ์ง€์›๋˜์ง€ ์•Š์Œ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์ƒ์ˆ˜ 0 int TRANSACTION_READ_UNCOMMITTED dirty read, non-repeatable read์™€ phantom read๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Œ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์ƒ์ˆ˜ 1 int TRANSACTION_READ_COMMITTED dirty read๋Š” ๊ธˆ์ง€๋˜๊ณ , non-repeatable read์™€ phantom read๋Š” ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Œ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์ƒ์ˆ˜ 2 int TRANSACTION_REPEATABLE_READ dirty read์™€ non-repeatable read๋Š” ๊ธˆ์ง€๋˜๊ณ , phantom read๋Š” ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Œ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์ƒ์ˆ˜ 4 int TRANSACTION_SERIALIZABLE dirty read, non-repeatable read์™€ phantom read ๋ชจ๋‘ ๊ธˆ์ง€๋จ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์ƒ์ˆ˜ 8