티스토리 뷰

Database

[DB] Charset 확인 test

애플자라 2008. 4. 23. 16:36
반응형

<%@ page contentType="text/html;charset=KSC5601" %>

<%@ page import="java.sql.*"%>

<%

Connection con = null;
ResultSet rs = null;
Statement stmt = null;

String url = "jdbc:mysql://localhost:3306/EMS51?useUnicode=true&characterEncoding=euckr";
String usr = "usr";
String pwd = "pwd
String drv = "org.gjt.mm.mysql.Driver";

String query1_pre = " UPDATE EBCD0030 SET CODE_NAME = '";
String query1_suf = "' WHERE CODE_TYPE = '00' AND CODE_CODE = ";
String query2 = " SELECT CODE_NAME EBCD0030 WHERE CODE_TYPE = '00' AND CODE_CODE = '01' ";

String value = request.getParameter("value");
value = value==null?"":value;

value = new String( value.getBytes("8859_1"), "EUC-KR" );

String codeName = "";

try {

 if( !value.equals("") ) {
 
 
  con = DriverManager.getConnection( url, usr, pwd );
  stmt = con.createStatement();
 
  stmt.executeUpdate( query1_pre + new String( value.getBytes("8859_1"), "EUC-KR" ) + query1_suf + " '01' " );
  stmt.executeUpdate( query1_pre + new String( value.getBytes("EUC-KR"), "EUC-KR" ) + query1_suf + " '02' " );
  stmt.executeUpdate( query1_pre + new String( value.getBytes("EUC-KR"), "8859_1" ) + query1_suf + " '03' " );
  stmt.executeUpdate( query1_pre + new String( value.getBytes("8859_1"), "8859_1" ) + query1_suf + " '04' " );
  stmt.executeUpdate( query1_pre + new String( value.getBytes("8859_1"), "UTF8" ) + query1_suf + " '05' " );
  stmt.executeUpdate( query1_pre + new String( value.getBytes("UTF8"), "UTF8" ) + query1_suf + " '06' " );
  stmt.executeUpdate( query1_pre + new String( value.getBytes("EUC-KR"), "UTF8" ) + query1_suf + " '07' " );
 
 }
 
 // rs = stmt.executeQuery( query2 );
 
 // if( rs.next() )
  // codeName= rs.getString("CODE_NAME");
 
 
} catch(Exception e) {
 
 out.println( e.toString() );
 
} finally {
 
 if( con!=null ) try { con.close(); } catch(Exception e) {};
 if( rs!=null ) try { rs.close(); } catch(Exception e) {};
 if( stmt!=null ) try { stmt.close(); } catch(Exception e) {};
}


%>




http://localhost:8181/ems51/jsp/test.jsp?value=테스트  확인




반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   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
글 보관함