Hibernate_主配置文件(Hibernate.cfg.xml)

来源:互联网 发布:c 获取数据库实例名 编辑:程序博客网 时间:2024/06/05 02:16

Hibernate.cfg.xml中:
  数据库连接信息、其他参数、映射信息。

常用配置源码:
  hibernate-distribution-3.6.0.Final\project\etc\hibernate.properties

<!DOCTYPE hibernate-configuration PUBLIC    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"><hibernate-configuration>    <!-- 通常,一个session-factory节点代表一个数据库 -->    <session-factory>    <!-- 1.数据库连接配置-->        <!-- 驱动配置 -->        <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>        <!-- 设置数据库的连接url-->        <property name="hibernate.connection.url">jdbc:oracle:thin:@127.0.0.1:1521:orcl</property>         <!-- 连接数据库的用户名-->        <property name="hibernate.connection.username">用户名</property>        <!-- 连接数据库的密码-->        <property name="hibernate.connection.password">密码</property>        <!--                 数据库方法配置,hibernate在运行的时候,会根据不同的方言生成符合当前数据库语法的sql        -->        <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>     <!-- 2. 其他相关配置 -->        <!-- 显示hibernate在运行时候执行的sql语句 -->        <property name="hibernate.show_sql">true</property>        <!-- 格式化sql -->        <property name="hibernate.format_sql">true</property>        <!-- 自动建表  -->        <property name="hibernate.hbm2ddl.auto">update</property>        <!--加载所有映射 -->        <mapping resource="/org/lee/entity/Student.hbm.xml"/>    </session-factory></hibernate-configuration>
原创粉丝点击