[转载]mysql+hibernate 中文乱码解决方法

参考:http://blog.csdn.net/qking93415981/archive/2007/08/21/1753248.aspx

1,设置mysql数据库编码为utf8

2,设置hibernate配置文件

在配置文件中添加两个property
<property name=”connection.useUnicode”>true</property>
<property name=”connection.characterEncoding”>UTF8</property>

<property name=”connection.driver_class”>
com.mysql.jdbc.Driver
</property>
<property name=”connection.url”>
jdbc:mysql://localhost:3306/test
</property>
<property name=”connection.useUnicode”>true</property>
<property name=”connection.characterEncoding”>UTF8</property>

No Comments

Post a Comment