乱码不是数据库的问题,跟classes.jar估计也没关系,跟你的java应用服务器字符集设置有关。你使用的是什么应用服务器?Tomcat、Resin、Weblogic其他的什么?如果不清楚怎么设置应用服务器的字符集,用以下的字符集转换方法在Java代码里尝试转换一下: public static String getString(String str) {
if (iStringConvert != 0) {
try {
sun.io.ByteToCharISO8859_1 tt = new sun.io.ByteToCharISO8859_1();
str = new String(tt.convertAll(str.getBytes()));
return str;
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
return str;
} public static String getString8859(String str) {
if (iStringConvert != 0) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("ISO8859_1");
String temp = new String(temp_t);
return temp;
}
catch (Exception e) {
System.out.println(e.toString());
str = "";
}
} return str;
} public static String getGBKBy8859(String str) {
if (iStringConvert != 0) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("ISO8859_1");
String temp = new String(temp_t, "GB2312");
return temp;
}
catch (Exception e) {
System.out.println(e.toString());
str = "";
}
} return str;
} public static String get8859ByGBK(String str) {
if (iStringConvert != 0) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("GB2312");
String temp = new String(temp_t, "ISO8859_1");
return temp;
}
catch (Exception e) {
System.out.println(e.toString());
str = "";
}
} return str;
} public static String getGB2312By8859(String str) {
if (iStringConvert != 0) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("ISO8859_1");
String temp = new String(temp_t, "GB2312");
return temp;
}
catch (Exception e) {
System.out.println(e.toString());
str = "";
}
}
return str;
} public static String getStringUTF8(String str) {
if (iStringConvert != 0) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("UTF-8");
String strRet = "";
for (int i = 0; i < temp_p.length(); i++) {
strRet += ("%" + Integer.toHexString(temp_t[i]));
}
return strRet;
}
catch (Exception e) {
System.out.println(e.toString());
str = "";
}
}
return str;
}
if (iStringConvert != 0) {
try {
sun.io.ByteToCharISO8859_1 tt = new sun.io.ByteToCharISO8859_1();
str = new String(tt.convertAll(str.getBytes()));
return str;
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
return str;
} public static String getString8859(String str) {
if (iStringConvert != 0) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("ISO8859_1");
String temp = new String(temp_t);
return temp;
}
catch (Exception e) {
System.out.println(e.toString());
str = "";
}
} return str;
} public static String getGBKBy8859(String str) {
if (iStringConvert != 0) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("ISO8859_1");
String temp = new String(temp_t, "GB2312");
return temp;
}
catch (Exception e) {
System.out.println(e.toString());
str = "";
}
} return str;
} public static String get8859ByGBK(String str) {
if (iStringConvert != 0) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("GB2312");
String temp = new String(temp_t, "ISO8859_1");
return temp;
}
catch (Exception e) {
System.out.println(e.toString());
str = "";
}
} return str;
} public static String getGB2312By8859(String str) {
if (iStringConvert != 0) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("ISO8859_1");
String temp = new String(temp_t, "GB2312");
return temp;
}
catch (Exception e) {
System.out.println(e.toString());
str = "";
}
}
return str;
} public static String getStringUTF8(String str) {
if (iStringConvert != 0) {
try {
String temp_p = str;
byte[] temp_t = temp_p.getBytes("UTF-8");
String strRet = "";
for (int i = 0; i < temp_p.length(); i++) {
strRet += ("%" + Integer.toHexString(temp_t[i]));
}
return strRet;
}
catch (Exception e) {
System.out.println(e.toString());
str = "";
}
}
return str;
}
解决方案 »
- oracle安装出现 "Oracle Database Configuration Assistant 失败'问题,详见内容
- 客户压力测试,反应数据库慢,请高手帮忙分析AWR报告。
- oracle的impdp和expdp的用法
- tomcat+oracle报错
- 怎么截取字符串 452;1824;3663;1547 为行?
- 怎样实现内联、外联??在线等待
- 如何把某一个用户的所有表和数据都导出来,然后如何再导入另一个库里按这个用户?
- oracle中如何获得sql语句的错误信息
- 问问not in和in的意思
- 各位我还有一个问题:如何在VB中用代码建立一个oracle数据源:在线等待!
- 请教:关于利用一个表更新第二个表格的方法问题
- 帮忙看一下,这个Update是什么意思?
request.setCharacterEncoding("GB2312");
response.setContentType(CONTENT_TYPE);
试试看.
都式了,还是不行,剧烈郁闷。