创建一个Hibernate的核心配置文件.

2016-10-30  本文已影响0人  蝌蚪1573

通知Hibernate连接是哪个数据库.
在src下创建一个hibernate.cfg.xml

<hibernate-configuration>
<session-factory>


<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql:///hibernate3_day01
</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123</property>


<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>

<!-- 可选的属性 -->
<!-- 显示SQL -->
<property name="hibernate.show_sql">true</property>
<!-- 格式化SQL -->
<property name="hibernate.format_sql">true</property>
<!-- hbm:映射 to DDL: create drop alter -->
<property name="hibernate.hbm2ddl.auto">update</property>

<!-- 通知Hibernate加载那些映射文件 ->
<mapping resource="cn/itcast/hibernate3/demo1/Customer.hbm.xml" />

</session-factory>
</hibernate-configuration>

上一篇 下一篇

猜你喜欢

热点阅读