์ตœ๊ทผ์— ์•Œ๊ฒŒ๋œ ์ง€์‹์„ ๊ณต์œ ํ•˜๊ณ ์ž ํฌ์ŠคํŒ…์„ ๋‚จ๊น๋‹ˆ๋‹ค.


์•„๋ž˜ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ EUC-KR(MSWIN949)๋กœ ์ธ์ฝ”๋”ฉ์„ค์ •์ด ๋˜์–ด์žˆ๋Š” DB์— varcharํƒ€์ž…์˜ ์ปฌ๋Ÿผ์— ํ•œ๊ธ€์„ ๋„ฃ์–ด๋‘์—ˆ์Šต๋‹ˆ๋‹ค.

select dump()๋ฅผ ์ด์šฉํ•ด์„œ ๋“ค์–ด๊ฐ€์žˆ๋Š” ๋ฐ์ดํƒ€๋ฅผ ํ—ฅ์‚ฌ๊ฐ’์œผ๋กœ ์ถœ๋ ฅํ•ด๋ณด๋ฉด 2๋ฐ”์ดํŠธ์งœ๋ฆฌ๋กœ ํ•œ๊ธ€์ด ์ž˜ ๋“ค์–ด๊ฐ€์žˆ์Œ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ์ž๋ฐ” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ด ๊ฐ’์„ Resultset.getBytes()๋กœ ์ฝ์–ด์™€์„œ ์ถœ๋ ฅํ•ด๋ณด๋‹ˆ 3๋ฐ”์ดํŠธ UTF-8 ์ธ์ฝ”๋”ฉ์œผ๋กœ ๋ณ€ํ™˜์ด ๋˜์–ด์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.



 


euc-kr ๋ฐ”์ดํŠธ๋ฅผ ์ฝ์–ด์™€์„œ ์ฒ˜๋ฆฌ๋ฅผ ํ•ด์•ผํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธด ๊ฒƒ์ธ๋ฐ์š”.


์˜ค๋ผํด ๋ฌธ์„œ๋ฅผ ์ฐพ์•„๋ดค๋”๋‹ˆ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ถ€๋ถ„์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.


How JDBC Drivers Perform Globalization Support Conversions

The techniques that the Oracle JDBC drivers use to perform character set conversion for Java applications depend on the character set the database uses. The simplest case is where the database uses the US7ASCII or WE8ISO8859P1 character set. In this case, the driver converts the data directly from the database character set to UTF-16, which is used in Java applications, and vice versa.

If you are working with databases that employ a non-US7ASCII or non-WE8ISO8859P1 character set (for example, JA16SJIS or KO16KSC5601), then the driver converts the data first to UTF-8 (this step does not apply to the server-side internal driver), then to UTF-16. For example, the driver always converts CHAR and VARCHAR2 data in a non-US7ASCII, non-WE8ISO8859P1 character set. It does not convert RAW data.


Note:

The JDBC drivers perform all character set conversions transparently. No user intervention is necessary for the conversions to occur.

 


 


์˜ค๋ผํด ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ํ•œ๊ธ€์„ ๊ธฐ๋ณธ์ ์œผ๋กœ utf-8 ๋ฐ์ดํƒ€๋กœ ๋ณ€ํ™˜์„ ํ•œ๋‹ค๋Š” ๊ฒƒ์ด์—ˆ์Šต๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ ์ž๋ฐ” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ฝ์–ด๋“ค์ผ ๋•Œ Resulset.getBytes()๋กœ ์ฝ์–ด์˜ค๋ฉด utf-8๋กœ ์ธ์ฝ”๋”ฉ๋œ ๋ฐ์ดํƒ€๊ฐ€ ๋‚˜์˜ค๊ฒŒ ๋˜๋Š” ๊ฒƒ์ด์ฃ .


๊ทธ๋ž˜์„œ getBytes()ํ•˜๋Š” ๊ฒƒ์„ getString()์œผ๋กœ ๋ฐ”๊พธ๊ณ  String.getBytes(encoding) ์œผ๋กœ bytes๋ฅผ ์ฝ์–ด์˜ค๋„๋ก ๋ฐ”๊ฟ”์„œ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.






Reference : http://docs.oracle.com/cd/B10500_01/java.920/a96654/advanc.htm