您的位置:首页 > 数据库 > MySQL

hibernate,mysql中文乱码解决方法

2009-08-28 12:23 501 查看
首先保证整个项目使用统一的编码如gb2312或utf8,在这里我使用的数据库为mysql,安装时设置为utf8编码,gb2312也成,然后在

hibernate.cfg.xml文件中设置你所使用的编码:

<property name="connection.useUnicode">true</property>
<property name="connection.characterEncoding">utf8</property>

或在设置数据库连接时采用如:

<property name="connection.url">jdbc:mysql://localhost:3306/db_group?useUnicode=true&characterEncoding=UTF-8</property>

的方式
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: