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 
</property> 
<property name="myeclipse.connection.profile">con</property> 
<mapping resource="com/hib/entity/Mytable.hbm.xml" /> 

</session-factory>

你可能感兴趣的:(xml,mysql,Hibernate,MyEclipse,jdbc)