我通过JDBC连接MYSQL输入中文出现问题,请指教! GBK是没问题的。 另外改字符集后要重启mysql 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 GBK没有问题,好像版本也有一定的关系,升级一下, 你可以在插入前转一下码。不用在数据库连接后面加一堆参数。 public static String UnicodeToChinese(String s){ try{ if(s==null&&s.equals("")) return ""; String newstring=null; newstring=new String(s.getBytes("ISO8859_1"),"gb2312"); return newstring; } catch(Exception e) { return s; } } public static String ChineseToUnicode(String s){ try{ if(s==null &&s.equals("")) return ""; String newstring=null; newstring=new String(s.getBytes("gb2312"),"ISO8859_1"); newstring=newstring.replaceAll("<","<"); newstring=newstring.replaceAll(">",">"); newstring=newstring.replaceAll("\n","<br/>"); newstring=newstring.replaceAll(" "," "); return newstring; } catch(Exception e) { return s; } } Socket 传输 大数据包的 问题…. 这个程序结果怎么是乱码? java中定义二维数组不同列为不同类型 weblogic8.1与Eclipse jdk的问题 高手帮忙看看一个过滤String[]中重复元素的方法!!! 想要美化界面,该怎么办? 谈谈一个设计理念!献给想上一层台阶的java初学者! jcreator有linux版么? J2SE,J2EE,J2ME有什么区别?分别是什么? 关于Provider的一个莫明其炒的错误 初学JAVA求教“引用”的含有 设计好的界面无法显示
try{ if(s==null&&s.equals(""))
return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
return newstring;
}
catch(Exception e)
{
return s;
}
}
public static String ChineseToUnicode(String s){
try{
if(s==null &&s.equals(""))
return "";
String newstring=null;
newstring=new String(s.getBytes("gb2312"),"ISO8859_1");
newstring=newstring.replaceAll("<","<");
newstring=newstring.replaceAll(">",">");
newstring=newstring.replaceAll("\n","<br/>");
newstring=newstring.replaceAll(" "," ");
return newstring;
}
catch(Exception e)
{
return s;
}
}