以前单位用的自己的连接池,感觉效果不怎么理想
后来使用了C3P0,经常在后台发现提示获取Connection失败,提示null。(由于是老项目,没有使用Spring来管理C3P0)昨天打印了下几个Connection数量,发现BusyConnection一直居高不下,没有释放。隔了半天才释放2-3个(正在使用的是100-400不等)最后我是强制到达指定数量后就resetPoolManage();注:我使用的是ComboPooledDataSource程序里使用都close了Connection链接,因为也有释放的效果,只是微乎其微,所以想应该不是conn.close的问题吧?还请大家帮忙支招!谢谢了~~
后来使用了C3P0,经常在后台发现提示获取Connection失败,提示null。(由于是老项目,没有使用Spring来管理C3P0)昨天打印了下几个Connection数量,发现BusyConnection一直居高不下,没有释放。隔了半天才释放2-3个(正在使用的是100-400不等)最后我是强制到达指定数量后就resetPoolManage();注:我使用的是ComboPooledDataSource程序里使用都close了Connection链接,因为也有释放的效果,只是微乎其微,所以想应该不是conn.close的问题吧?还请大家帮忙支招!谢谢了~~
给你个配置文件样例:
proxoolconf.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>pool1</alias>
<driver-url>jdbc:oracle:thin:@10.4.1.12:1521:DB</driver-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver-properties>
<property name="user" value="user"/>
<property name="password" value="user"/>
</driver-properties>
<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<maximum-new-connections>20</maximum-new-connections>
<prototype-count>5</prototype-count>
<maximum-connection-count>20</maximum-connection-count>
<minimum-connection-count>3</minimum-connection-count>
</proxool>
</something-else-entirely>
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"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration><session-factory>
<property name="hibernate.connection.provider_class">
org.hibernate.connection.ProxoolConnectionProvider
</property>
<property name="hibernate.proxool.pool_alias">pool1</property>
<property name="hibernate.proxool.xml">ProxoolConf.xml</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="show_sql">true</property>
...........</session-factory></hibernate-configuration>