µ¥ÀÌŸº£À̽º¿¡¼­ÀÇ ÇÑ±Û Ã³¸® ¹æ¹ý.


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :±è´öÅ 1998³â 1¿ù 12ÀÏ 15:47:30

In Reply to: ±è´öÅ°­»ç´Ô²² jdbc¿¡¼­ ÇѱÛó¸® posted by °í°æȯ on 1998³â 1¿ù 12ÀÏ 13:33:40:

±×·¸°Ô º¯È¯ÇÏ¸é ¿ø·¡ÀÇ ½ºÆ®¸µÀ¸·Î µ¹¾Æ¿À´Ï±ñ ¾Æ¹«·± Àǹ̰¡ ¾ø½À´Ï´Ù.


Áö±Ý »ç¿ëÇÏ°í °è½Å JDBC µå¶óÀ̹ö°¡ imaginaryÀÇ mSQL JDBC µå¶óÀ̹öÇÏ°í
Áõ»óÀÌ ¶È°°±º¿ä (°¡Àå ÀϹÝÀûÀÎ Áõ»ó)
Áï, JDBC µå¶óÀ̹ö°¡ µ¥ÀÌŸº£À̽ºÀÇ µðÆúÆ® ÀÎÄÚµù (¿ì¸®³ª¶óÀÇ °æ¿ì "KSC5601")°ú
º¯È¯ÇÏ¿©¾ß Çϴµ¥, "8859_1" ÀÎÄÚµùÀ¸·Î º¯È¯Çؼ­ »ý±â´Â ¹®Á¦ÀÎ °Í °°±º¿ä.
´ÙÀ½ ¿¹Á¦¸¦ ÂüÁ¶Çؼ­ ½ÇÇàÇغ¸°í °á°ú¸¦ ¿Ã·ÁÁֽñ⠹ٶ÷.


¶ÇÇÑ, JDBC µå¶óÀ̹ö¸¶´Ù ÄÚµå º¯È¯ÀÌ ´Ù¸¦ ¼ö ÀÖÀ¸´Ï±ñ,
´Ù¸¥ µå¶óÀ̹ö¸¦ »ç¿ëÇÒ ¶§´Â Á¶»çÇØ º»ÈÄ,
toDB ¸Þ½îµå¿Í fromDB ¸Þ½îµå¸¦ ÀûÀýÈ÷ ¹Ù²ÞÀ¸·Î½á ¿ø½Ã È­ÀÏÀÇ ´Ù¸¥ ºÎºÐÀº
¼öÁ¤ÇÒ ÇÊ¿ä°¡ ¾ø°Ô µË´Ï´Ù.
Áï, ÄÚµå º¯È¯À» Á¦´ë·Î ÇÏ´Â JDBC µå¶óÀ̹ö·Î ¹Ù²Ù°Ô µÉ °æ¿ì¿¡´Â
toDB, fromDB ¸Þ½îµåÀÇ ¸öü¸¦ { return str; }·Î ¹Ù²Ù¾îÁֱ⸸ ÇÏ¸é µË´Ï´Ù.
ÇöÀç·Î¼­´Â ÀÌ ¹æ¹ýÀÌ °¡Àå °£´ÜÇϸ鼭 ´ú ±ÍÂúÀº ¹æ¹ýÀÏ °Í °°±º¿ä.


µ¥ÀÌŸº£À̽º·Î SQL ¹®ÀåÀ» º¸³¾¶§µµ, °¡Á®¿Ã¶§µµ ¸ðµÎ ÄÚµå º¯È¯À»
ÇÏ´Â µ¥, °¡Á®¿Ã¶§¿Í´Â ´Þ¸® º¸³¾¶§ÀÇ ±³Á¤ ¹æ¹ýÀÌ ´Þ¶ó¼­,
ÄÚµå º¯È¯À» ±³Á¤ÇÏ´Â ¸Þ½îµå¸¦ µû·Î ½á¾ß ÇÏ´Â °ÍÀÔ´Ï´Ù.




====== JDBCBugWorkaround.java ================
import java.sql.*;


class JDBCBugWorkaround
{ public static void main(String[] args)
throws ClassNotFoundException, SQLException,
java.io.UnsupportedEncodingException
{ Class.forName("com.imaginary.sql.msql.MsqlDriver");
Connection con = DriverManager.getConnection(
"jdbc:msql://" + args[0]);


Statement stmt = con.createStatement();
ResultSet rs =
stmt.executeQuery( toDB("SELECT * FROM student WHERE name = '±èö¼ö'") );


while(rs.next())
{
int id = rs.getInt("id");
String name = fromDB(rs.getString("name"));
String phone = rs.getString("phone");
System.out.println("id: " + id +
", name: " + name +
", phone: " + phone);
}
stmt.close();
con.close();
}


static String toDB(String str)
throws java.io.UnsupportedEncodingException
{ return new String( str.getBytes("KSC5601"), "8859_1" );
}


static String fromDB(String str)
throws java.io.UnsupportedEncodingException
{ return new String( str.getBytes("8859_1"), "KSC5601" );
}
}





´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]