我以前也碰到类似的问题,mysql5.0版本的 中文存不进去由来采用在进行数据库操作前先执行sql语句“set charset=gbk”就可以了

解决方案 »

  1.   

    如果采用连接池,在配置参数中加就可以了。
    proxool:
    <driver-url>jdbc:mysql://192.168.0.100/testdb?useUnicode=true&amp;characterEncoding=utf-8</driver-url>
      

  2.   

    嗯,指定url的时候设置一下就好了
      

  3.   

    编码保持一致
    <driver-url>jdbc:mysql://192.168.0.100/testdb?useUnicode=true&characterEncoding=GBK</driver-url>建库时,set charset=gbk
      

  4.   

    建库时加一个charset=gbk,页面的编码也用gbk,数据库连接的时候也用gbk:useUnicode=true&amp;characterEncoding=gbk,然后在web.xml写一个Fiter,也用GBK,就OK了
      

  5.   

    页面编码UTF-8,数据库字符集UTF-8,request中也设置UTF-8,Tomcat的Get和POST方法也设UTF-8
    -----------
    让乱码无处可藏!
      

  6.   

    编码保持一致
    <driver-url>jdbc:mysql://192.168.0.100/testdb?useUnicode=true&characterEncoding=GBK</driver-url>建库时,set charset=gbk
      

  7.   

    找到my.ini文件,搜索default-character-set,把其值设为gb2312
    另外,hibernate.cfg.xml文件中
    <property name="connection.url">jdbc:mysql://localhost/harmony</property>不要用这种<property name="connection.url">jdbc:mysql://localhost/harmony?useUnicode=true&characterEncoding=gb2312</property>