public String outStr(String strValue)
{
try
{
String strBuffer=strValue;
byte[] byteBuffer=strBuffer.getBytes("ISO8859-1");
String strReturn=new String(byteBuffer,"gb2312");
return strReturn;
}
catch(Exception e)
{
return null;
}
}

解决方案 »

  1.   

    eg:
    wpTp = rs.getString("wptp");
    if(wpTp!=null&&!wpTp.equals("")){
       wpTp = new String(wpTp.getBytes("iso8859_1"),"GBK");
    }
      

  2.   

    进过高手的指点代码修改后我成功的案例!!!
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    public class jdbc
    {
       public static void main(String args[])
    {
    *String url="jdbc:mysql://   /tzw?useUnicode=true&characterEncoding=GB2312";
    try
    {
    Class.forName("          ");
    Connection conn=DriverManager.getConnection(url,"root","");
                           
    Statement stmt=conn.createStatement();
    ResultSet rs=stmt.executeQuery("select id,name,address from apple");
    while (rs.next())
    {
    System.out.println(" ID :"+rs.getInt("id")+"  名字 : "+rs.getString("name")+"   地址 : "+rs.getString("address"));}
    rs.close();
    stmt.close(); 
    conn.close();
    }
    catch(Exception e)
    {
    e.getMessage();
    e.printStackTrace();
                                  
    }}
    }
      

  3.   

    两种方法 ,
    一个是在连接时,连接字符串加入?useUnicode=true&characterEncoding=gb2312,如下:
    jdbc:mysql://192.168.1.180/hasons1?useUnicode=true&characterEncoding=gb2312一种是显示时使用:
    new String(wpTp.getBytes("iso8859_1"),"GB2312")来转换,显示就可以了。
      

  4.   

    在url后加上useUnicode=true&characterEncoding=GB2312
      

  5.   

    jdbc:mysql://localhost/experiment?user=root&password=password&useUnicode=true&characterEncoding=gb2312这条是连接mysql处理中文的基本环节,我现在一直用mysql做开发,感觉还不错