zoukankan      html  css  js  c++  java
  • Hibernate----配置文件Hibernate.cfg.xml

    在Hibernate中大配置一般命名为“HIbernate.cfg.xml”

      Hibernate配置文件主要用于配置数据库连接和HIbernate运行时所需要的各种特性。

    <?xml version='1.0' encoding='utf-8'?>
    <!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>
            <!-- 数据库JDBC驱动 -->
            <property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
            <!-- 数据库URL -->
            <property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
            <!-- 数据库用户名 -->
            <property name="connection.username">szj</property>
            <!-- 数据库密码 -->
            <property name="connection.password">szj</property>
            <!-- 方言 -->
            <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
            
            <!-- 输出所有sql语句到控制台 -->
            <property name="hibernate.show_sql">true</property>
            
            <!-- 在 log 和 conlose 中打印出更漂亮SQL -->
            <property name="hibernate.format_sql">true</property>
            
            <!-- hbm2ddl  -->
            <property name="hibernate.hbm2ddl.auto">update</property>
            
            <!-- 指定当前session范围和上下文 thread指当前线程来跟踪管理 -->
            <property name="current_session_context_class">thread</property>
            <!-- 映射文件配置,注意配置文件名必须包含其相对于classpath的全路径 -->
            <mapping resource="cn/happy/entity/Student.hbm.xml"/>
            
        </session-factory>
        
    </hibernate-configuration>
  • 相关阅读:
    sql常用语句
    java学习(东软睿道)2019-09-06(预课)《随堂笔记》
    Servlet和JSP学习总结
    由字符集的转换想到的问题
    mysql主从搭建
    CentOS 源码安装MySQL5.7
    Linux搭建FTP服务器
    连接MySQL报错误代码 ERROR 1045时的解决方案
    [js]使用百度编辑器uediter时遇到的一些问题(span,div等被过滤)
    [css]将textarea前的文字设置在左上角
  • 原文地址:https://www.cnblogs.com/szj-ang/p/HIbernate.html
Copyright © 2011-2022 走看看