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 即可。