热门关键字: jsp web pl/sql pl webwor   →开发工具  操作系统
当前位置 : 无忧IT编程网 > J2EE开发 > Hibernate > 正文

hibernate学习笔记(一)---------hibernate.cfg.xml文件的具体配置

来源:转载作者:51itcn时间:08-07-29

一、首先学习hibernate.cfg.xml配置文件的具体配置
<?xml version="1.0" encoding="UTF-8"?>

<!--指定该文件的官方dtd-->
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" >
<hibernate-configuration>
  <session-factory>
    <!-- 显示sql语言 -->
    <property name="show_sql">true</property>
    <!-- sql语言 -->
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <!-- jdbc驱动程式 -->
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <!-- jdbc url -->
    <property name="connection.url">jdbc:mysql://localhost:3306/test</property>
    <!-- 数据库用户名 -->
    <property name="connection.username">root</property>
    <!-- 数据库密码 -->
    <property name="connection.password">wyq</property>
    <!-- C3P0连接池设定 -->
    <!--最小连接数-->
    <property name="c3p0.min_size">5</property>
    <!--最大连接数-->
    <property name="c3p0.max_size">20</property>
   <!--延迟所允许的时间-->
    <property name="c3p0.timeout">1800</property>
   <!--缓存所允许的最大连接数-->
    <property name="c3p0.max_statements">50</property>
    <!-- 每隔100笔资料送入资料库,清除缓存(定期清除缓存,减小压力) -->
    <property name="hibernate.jdbc.batch_size">100</property>
    <!-- 设定事务管理的工厂类 -->
    <property name="hibernate.transaction.factiory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
   <mapping resource="com/wyq/hibernate/pojo/User.hbm.xml"/>
   <mapping resource="com/wyq/hibernate/pojo/TUser.hbm.xml"/>
   <mapping resource="com/wyq/hibernate/pojo/Room.hbm.xml"/>
  </session-factory>
</hibernate-configuration>
需要的jar包有c3p0.jar,hibernate3.jar,数据库.jar,log4j.jar

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 验证码: 验证码
查看所有评论
站长推荐