<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/filemanager?useUnicode=true&characterEncoding=utf-8</property>
若<property name="connection.useUnicode" >true</property>
<property name="connection.characterEncoding" >utf-8</property>
connection必须加
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
这里不要“connection.”加了反而“The dialect was not set. Set the property hibernate.dialect”
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<mapping resource="com/huawei/ssh/model/File.hbm.xml"/>
<mapping resource="com/huawei/ssh/model/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
可以采用 <property name="connection.useUnicode">root</property>
建议使用Hibernate Synchronizer插件 可生成配置文件、映射文件并生成model类
乱码http://blog.163.com/xueling1231989@126/blog/static/10264080720123602241891/
http://www.blogjava.net/i369/articles/194855.html hibernate配置
本文深入解析Hibernate配置文件,具体展示了如何通过XML格式配置连接MySQL数据库,实现对象关系映射(ORM)。重点包括数据库连接参数设置、方言选择、SQL显示与格式化,以及实体类映射文件的导入。
122

被折叠的 条评论
为什么被折叠?



