我用的SQLyog 查询MySql 数据库的表显示出来的不是中文.我看了字符设置是utf8.
现在这种情况下,我在jsp页面查询时可以看到中文. 请问大家知道如何在查询时SQLyog也能看到中文吗? 20份还有如果我登陆验证用户名使用中文,请问怎么在后面比较.我现在验证时.输入的和数据库相同的中文,比较出来确是false. 请帮助? 20分周五完结贴

解决方案 »

  1.   

    在第一个问题中SQLyog不知道是什么东东.
    第二个问题:当你提交表单后你所输入的内容就变成了8859-1编码格式,与数据库的utf-8肯定是不相符的.
      

  2.   

    给你一个转换的程序
    存入中文的时候先toDataBase();
    取出的时候codeToString()一下
    package db;public class codeToString {
    public String codeToString(String str){
    String s=str;
    try{
    byte tempB[]=s.getBytes("ISO8859-1");
    s=new String(tempB);
    return s;
    }catch(Exception e){
    return s;
    }
    }
    public static String toDataBase(String source){
            if (source == null) return null;
            try{
                String s = new String(source.getBytes("gb2312"),"ISO-8859-1");
                return s;
            }catch(Exception uee){
                String s1 = null;
                return s1;
            }
         }}
      

  3.   

    在装MySql的时候,里面有一项是,可以将mysql内部设置为中文的
      

  4.   

    我们当年做毕业设计的时候,也遇到这个问题
    不过专门写个bean九完全搞定。
    以后在html里面遇见String类型的变量,前面加上chStr(str)就可以搞定。
    package beans;public class chStr {
    public String chStr(String str){
    if(str==null){
    str="";
    }else{
    try{
    str=(new String(str.getBytes("iso-8859-1"),"GB2312")).trim();
    }catch(Exception e){
    e.printStackTrace(System.err);
    }
    }
    return str;
    }
    public static void main(String args[]) { }
    }