日期:2014-05-16  浏览次数:20585 次

Hibernate配置文件中指定MySQL数据库的编码方式

Hibernate配置文件中指定MySQL数据库的编码方式:

1)

<hibernate-configuration>?

<session-factory>?
<property name="dialect">?
org.hibernate.dialect.MySQLDialect?
</property>?
<property name="connection.url">?
jdbc:mysql://127.0.0.1:3306/db?useUnicode=true&amp;characterEncoding=utf-8?
</property>?
<property name="connection.username">root</property>?
<property name="connection.password">root</property>?
<property name="connection.driver_class">?
com.mysql.jdbc.Driver?
</property>?
<property name="myeclipse.connection.profile">con</property>?
<mapping resource="com/hib/entity/Mytable.hbm.xml" />?

</session-factory>?

2)

<hibernate-configuration>?

<session-factory>?
<property name="dialect">?
org.hibernate.dialect.MySQLDialect?
</property>?
<property name="connection.url">?
jdbc:mysql://127.0.0.1:3306/db

</property>

</hibernate-configuration><property name="connectio.useUnicode">true</property>?
<property name="connection.characterEncoding">utf-8</property>?
<property name="connection.username">root</property>?
<property name="connection.password">root</property>?
<property name="connection.driver_class">?
com.mysql.jdbc.Driver?