关于JAVA从MYSQL中取数据乱码问题 从MYSQL中取出的中文字段数据乱码这个问题怎么样才能解决呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /** * 字符集转换 * * @param s * ISO-8859-1字符 * * @return GBK字符 */ public static String toChinese(String s) throws UnsupportedEncodingException { if (s == null || s.trim().length() == 0) { return null; } else { byte aa[] = s.getBytes("ISO-8859-1"); String ss = new String(aa, "GBK"); return ss; } } /** * 字符集转换 * * @param s * GBK字符 * * @return ISO-8859-1字符 */ public static String toEnglish(String s) throws UnsupportedEncodingException { if (s == null || s.trim().length() == 0) { return null; } else { byte aa[] = s.getBytes("GBK"); String ss = new String(aa, "ISO-8859-1"); return ss; } }希望对你有用,我联oracle开始也是乱码,通过上面的方法解决了。 设置mysql的连接URL,在网上搜索一下,很多的。 String str = new String(str.getBytes("ISO-8859-1"),"GBK"); jframe 中界面最小化后图形消失的问题 关于JTree 的问题! 怎么样获得一个ResultSet的长度? 如何在JTextPane中设置超链接? 新手想学JAVA.. 请问哪里有JB9的下载,急,多谢啦 一个包的问题 在线等待,关于数字签名中的javakey 我的appletviewer怎么不能浏览applet呢! 关于Apache SOAP 的问题 怎么实现将windows的文本文件拖放到Jtextarea中呢?? 怎么样把一个自定义的类型的数据写入一个文件再按照这个类型读
* 字符集转换
*
* @param s
* ISO-8859-1字符
*
* @return GBK字符
*/
public static String toChinese(String s)
throws UnsupportedEncodingException {
if (s == null || s.trim().length() == 0) {
return null;
} else {
byte aa[] = s.getBytes("ISO-8859-1");
String ss = new String(aa, "GBK");
return ss;
}
} /**
* 字符集转换
*
* @param s
* GBK字符
*
* @return ISO-8859-1字符
*/
public static String toEnglish(String s)
throws UnsupportedEncodingException {
if (s == null || s.trim().length() == 0) {
return null;
} else {
byte aa[] = s.getBytes("GBK");
String ss = new String(aa, "ISO-8859-1");
return ss;
}
}希望对你有用,我联oracle开始也是乱码,通过上面的方法解决了。