码迷,mamicode.com
首页 > Web开发 > 详细

hibernate.cfg.xml

时间:2015-05-24 12:56:35      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

<?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>
    <!-- 一个sessionFactory代表数据库的一个连接 -->
<session-factory>
    <!-- 链接数据库的用户名 -->
    <property name="connection.username">root</property>
    <!-- 链接数据库的密码 -->
    <property name="connection.password">123456</property>
    <!-- 链接数据库的驱动 -->
    <property name="connection.driver_class">
        com.mysql.jdbc.Driver
    </property>
    <!-- 链接数据库的url -->
    <property name="connection.url">
        jdbc:mysql://localhost:3306/test_hibernate
    </property>
    <!-- 
        方言
        告诉hibernate用什么样的数据库
    -->
    <property name="dialect">
        org.hibernate.dialect.MySQLDialect
    </property>
    <!-- 
        validate 加载hibernate时,验证数据库的结构  默认值
        update  加载hibernate时,检查数据库,如果表不存在,则创建,如果存在,则更新
        create  每次加载hiberante,都会创建表
        create-drop  每次加载hiberante,创建,卸载hiberante时,销毁
    -->
    <property name="hbm2ddl.auto">update</property>
    <property name="show_sql">true</property>
    <property name="format_sql">true</property>
    <mapping resource="com/sn/domain/Classes.hbm.xml" />
    <mapping resource="com/sn/domain/Student.hbm.xml" />
</session-factory>
</hibernate-configuration>

 

hibernate.cfg.xml

标签:

原文地址:http://www.cnblogs.com/jsnan/p/4525643.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!