Hibernate+mysql 中文乱码解决方案

来源:互联网 发布:淘宝直播小陈珍珠 编辑:程序博客网 时间:2024/05/24 16:15
 解决方法
在hibernate.cfg.xml中应该这样写
<property name="connection.url">jdbc:mysql://localhost:3306/yidishui?useUnicode=true&amp;characterEncoding=UTF-8</property>

如果用hibernate.properties
#hibernate.connection.url jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8

ps:处理中文的话,characterEncoding用GBK一样可以。
但字节编码问题最好的解决方法还是统一使用UTF-8!!!

原创粉丝点击