我用下面的方法转换后存还是乱码
<%!
public String toChinese(String strvalue){
try{
if(strvalue==null)
return null;
else{
strvalue=new String(strvalue.getBytes("ISO8859_1"),"GBK");
return strvalue;
}
}catch(Exception e){
return null;
}
}%>
还有什么别的方法吗?我想是不是连接池没有配好
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/feaket?username=root;password=sa;useUnicode=true;characterEncoding=GB2312</value>
</parameter>
<%!
public String toChinese(String strvalue){
try{
if(strvalue==null)
return null;
else{
strvalue=new String(strvalue.getBytes("ISO8859_1"),"GBK");
return strvalue;
}
}catch(Exception e){
return null;
}
}%>
还有什么别的方法吗?我想是不是连接池没有配好
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/feaket?username=root;password=sa;useUnicode=true;characterEncoding=GB2312</value>
</parameter>
public String getStr(String str) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("ISO8859-1");
String temp = new String(temp_t);
return temp;
} catch(Exception e) {
}
return null;
}
%>
还有转换成其他的码因为可能你的mysql不支持gb2312
那你就试试utf-8
还有转换成其他的码因为可能你的mysql不支持gb2312
那你就试试utf-8
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost/feaket?username=root;password=sa;useUnicode=true;characterEncoding=GB2312</value>
</parameter>