hibernate 中文问题(高分)
操作系统是 win2000,编码GBK
JDK 1.5
数据库 MySQL 5.0,字符编码 latin1
测试hibernate2时配置文件如下:
<?xml version='1.0' encoding='GBK'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/db_app?useUnicode=true&characterEncoding=iso_8859_1
</property>
<property name="connection.useUnicode">true</property>
<property name="connection.characterEncoding">iso_8859_1</property>
<property name="connection.username">kofsky</property>
<property name="connection.password">kofsky</property>
<mapping resource="user.hbm.xml"/>
</session-factory>
</hibernate-configuration>
为什么写入数据库的时候,中文为乱码?
我在用JDBC的时候,中文问题可以解决的很好啊。就是写入时转为iso_8859_1,读出时转化为gbk 。按道理说,hibernate设置编码为iso_8859_1时,是能够正确写入的嘛。
多谢了。