spring+hibernate的c3p0 连接池配置
2011-03-05 15:39
351 查看
网上很多关于C3P0在spring+hibernate中的配置,几乎没有完全正确的,以下是根据c3p0的文档,又试验过多次,得出如下配置是正确的:
<!-- com.mchange.v2.c3p0.ComboPooledDataSource -->
<!-- start-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${driverClass}" />
<property name="jdbcUrl" value="${jdbcUrl}" />
<property name="user" value="${user}" />
<property name="password" value="${password}" />
<property name="minPoolSize">
<value>4</value>
</property>
<property name="maxPoolSize">
<value>20</value>
</property>
<property name="maxIdleTime">
<value>1800</value>
</property>
<property name="acquireIncrement">
<value>2</value>
</property>
<property name="maxStatements">
<value>0</value>
</property>
<property name="initialPoolSize">
<value>2</value>
</property>
<property name="idleConnectionTestPeriod">
<value>1800</value>
</property>
<property name="acquireRetryAttempts">
<value>30</value>
</property>
<property name="breakAfterAcquireFailure">
<value>true</value>
</property>
<property name="testConnectionOnCheckout">
<value>false</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.connection.release_mode">auto</prop>
<prop key="hibernate.autoReconnect">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>ht/gisoa/entity/CmppSubmitCache.hbm.xml</value>
<value>ht/gisoa/entity/CmppDeliver.hbm.xml</value>
<value>ht/gisoa/entity/CmppSubmit.hbm.xml</value>
<value>ht/gisoa/entity/CmppReport.hbm.xml</value>
<value>ht/gisoa/entity/SGpstraceinfo.hbm.xml</value>
<value>ht/gisoa/entity/SDeviceinfo.hbm.xml</value>
<value>ht/gisoa/entity/SLbstraceinfo.hbm.xml</value>
<value>ht/gisoa/entity/Lbsschemainfo.hbm.xml</value>
</list>
</property>
</bean>
<!--end-->
<!-- com.mchange.v2.c3p0.ComboPooledDataSource -->
<!-- start-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${driverClass}" />
<property name="jdbcUrl" value="${jdbcUrl}" />
<property name="user" value="${user}" />
<property name="password" value="${password}" />
<property name="minPoolSize">
<value>4</value>
</property>
<property name="maxPoolSize">
<value>20</value>
</property>
<property name="maxIdleTime">
<value>1800</value>
</property>
<property name="acquireIncrement">
<value>2</value>
</property>
<property name="maxStatements">
<value>0</value>
</property>
<property name="initialPoolSize">
<value>2</value>
</property>
<property name="idleConnectionTestPeriod">
<value>1800</value>
</property>
<property name="acquireRetryAttempts">
<value>30</value>
</property>
<property name="breakAfterAcquireFailure">
<value>true</value>
</property>
<property name="testConnectionOnCheckout">
<value>false</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.connection.release_mode">auto</prop>
<prop key="hibernate.autoReconnect">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>ht/gisoa/entity/CmppSubmitCache.hbm.xml</value>
<value>ht/gisoa/entity/CmppDeliver.hbm.xml</value>
<value>ht/gisoa/entity/CmppSubmit.hbm.xml</value>
<value>ht/gisoa/entity/CmppReport.hbm.xml</value>
<value>ht/gisoa/entity/SGpstraceinfo.hbm.xml</value>
<value>ht/gisoa/entity/SDeviceinfo.hbm.xml</value>
<value>ht/gisoa/entity/SLbstraceinfo.hbm.xml</value>
<value>ht/gisoa/entity/Lbsschemainfo.hbm.xml</value>
</list>
</property>
</bean>
<!--end-->
相关文章推荐
- Spring+Hibernate 配置和使用c3p0和proxool连接池
- Spring+Hibernate的连接池配置(c3p0,proxool)
- Spring 结合Hibernate 配置 C3P0 连接池
- Spring 结合Hibernate 配置 C3P0 连接池
- Spring+Hibernate的连接池配置(c3p0,proxool)
- Spring 结合Hibernate 配置 C3P0 连接池(转)
- spring+hibernate的c3p0 连接池配置 转
- Spring + Hibernate 配置 C3P0 连接池
- Spring+Hibernate 配置和使用c3p0和proxool连接池
- Spring c3p0连接池通过Hibernate配置
- Hibernate 中配置C3P0连接池
- Hibernate连接池的配置(hibernate和hibernate+spring)
- Hibernate支持第三方的连接池,官方推荐的连接池是C3P0,Proxool,以及DBCP。在配置连接池时需要注意的有三点
- Hibernate 连接池的三种配置方式:dbcp , c3p0
- 关于hibernate配置c3p0连接池连接mysql问题
- (绝对有效)sqlserver2000链接proxool连接池,终于配置出spring整合struts,hibernate annotation(pool数据池,sqlserver2000数据库)
- 最新版的SSH框整合(Spring 3.1.1 + Struts 2.3.1.2 + BoneCP + Hibernate 4.1)更新增加C3P0和EhCache配置
- 在spring中通过hibernate配置C3P0
- spring+hibernate:在applicationCOntext.XML中配置C3P0参数说明
- Hibernate中配置C3P0连接池