Java와 Mysql 연동시 한글 깨짐 문제 해결법

public String toMySQL(String msg){
  
  try{
   return new String(msg.getBytes(“KSC5601”), “8859_1”);
  }catch(Exception e){
   e.printStackTrace();
   return null; 
  } 
 }


 public String toJava(String msg){
  
  try{
   return new String(msg.getBytes(“8859_1”), “KSC5601”);
  }catch(Exception e){
   e.printStackTrace();
   return null; 
  }
 }

두개의 메서드를 구현해주어 전송하거나 전송 받을 쿼리문자를

인코딩 해주면 된다.

바로가기