我也有这个问题 我用的是mysql 把中文存到数据库里 然后查看数据库 都是乱吗 也不知道是 数据库的问题还是JAVA的问题

解决方案 »

  1.   

    mysql用这个url可以解决jdbc:mysql://192.168.0.3:3306/SH_Game?\
    user=game_user&password=game_pass&useUnicode=true&characterEncoding=GBKsqlserver可以要自己转换编码才不是乱码
    new String(str.getBytes("8859_1"),"gbk")...不晓得是不是这样试的
      

  2.   

    加入request.setCharacterEncoding("GBK");
      

  3.   

    aa="乱码的字符串";
    aa=new String(aa.getBytes("ISO-8859-1"),"GBK");
    然后再插入数据库就OK了。
      

  4.   

    如果还没投入运行,装数据库的时候最好选用unicode的。
      

  5.   


        public static String getWriteStr(String str) {
            try {
                String temp_p = str;
                byte[] temp_t = temp_p.getBytes("GBK");
                String unicode = new String(temp_t,"ISO8859-1");
                return unicode;
            }
            catch(Exception e) {
                return "null";
            }
        }    public static String getReadStr(String str) {
            try {
                String temp_p = str;
                byte[] temp_t = temp_p.getBytes("ISO8859-1");
                String unicode = new String(temp_t,"GBK");
                return unicode;
            }
            catch(Exception e) {
                return "null";
            }
        }