hibernate 基本配置和使用

 1: hibernate.cfg.xml

<?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>

 <session-factory> 
   <!-- 下边的的4个property为配置proxool连结池 -->
    <property name="hibernate.proxool.pool_alias">partspool</property>
    <property name="hibernate.proxool.xml">proxool.xml</property>
    <property name="connection.provider_class">
      org.hibernate.connection.ProxoolConnectionProvider
    </property>
 </session-factory>

</hibernate-configuration>

 

2: hibernate.properties

hibernate.connection.pool_size 30

 

hibernate.proxool.pool_alias partspool

hibernate.proxool.xml proxool.xml

 

hibernate.show_sql true

hibernate.format_sql true

hibernate.max_fetch_depth 1

hibernate.jdbc.fetch_size 70

hibernate.jdbc.batch_size 125

 

3:proxool.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- the proxool configuration can be embedded within your own application's.
       Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
       <proxool>
           <alias>partspool</alias>
           <driver-url>
               jdbc:oracle:thin:@192.168.1.22:1521:oraclecn
           </driver-url>
           <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
           <driver-properties>
               <property name="user" value="test" />
               <property name="password" value="test" />
           </driver-properties>
           <house-keeping-sleep-time>80000</house-keeping-sleep-time>
           <prototype-count>20</prototype-count>
           <maximum-connection-count>30</maximum-connection-count>
           <minimum-connection-count>10</minimum-connection-count>
       </proxool>
</something-else-entirely>

 

4:

如果想直接获取 connection连接的话,可以通过 session.connection() 获取。

但是不用关闭 此 connection 因为它是缓冲池的对象,只关session 即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值