是字符集的问题,需要进行字符集转换,给你个函数吧://***************************************************
//名称:ChangeCode
//功能:转换指定字符串的字符集(字符编码)
//输入:strSource: 要转换的字符串; strCodeFrom: 源字符集; strCodeTo: 目的字符集
//输出:
//返回:转换之后的字符串
//***************************************************
public static String ChangeCode(
String strSource,
String strCodeFrom,
String strCodeTo)
{
byte[] baTemp = null;
try
{
baTemp = strSource.getBytes(strCodeFrom);
strSource = new String(baTemp, strCodeTo);
}
catch (Exception e)
{
return (e.toString());
} return (strSource);
}

解决方案 »

  1.   

    I. 取中文 用 JDBC 执行 SELECT 语句从服务器端读取数据(中文)后,将数据用 APPEND 方法加到 TextArea(TA) ,不能正确显示。但加到 List 中时,大部分汉字却可正确显示。 将数据按“ISO-8859-1” 编码方式转化为字节数组,再按系统缺省编码方式 (Default Character Encoding) 转化为 STRING ,即可在 TA 和 List 中正确显示。 程序段如下: dbstr2 = results.getString(1); //After reading the result from DB server,converting it to string. dbbyte1 = dbstr2.getBytes(“iso-8859-1”); dbstr1 = new String(dbbyte1); 在转换字符串时不采用系统默认编码方式,而直接采用“ GBK” 或者 “GB2312” ,在 A 和 B 两种情况下,从数据库取数据都没有问题。 II. 写中文到数据库 处理方式与“取中文”相逆,先将 SQL 语句按系统缺省编码方式转化为字节数组,再按“ISO-8859-1”编码方式转化为 STRING ,最后送去执行,则中文信息可正确写入数据库。 程序段如下: sqlstmt = tf_input.getText(); //Before sending statement to DB server,converting it to sql statement. dbbyte1 = sqlstmt.getBytes(); sqlstmt = newString(dbbyte1,”iso-8859-1”); _stmt = _con.createStatement(); _stmt.executeUpdate(sqlstmt);