Oracle - 连接池与spring框架 [英] Oracle - connection Pooling with spring framework

查看:699
本文介绍了Oracle - 连接池与spring框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试在Spring Framework的帮助下实现Oracle连接池。我们正在使用DBCP连接池方法。然而,DBCP和spring之间的集成并没有那么顺利。

We are trying to implement Oracle connection pooling with the help of Spring Framework. We are using DBCP connection pooling method. However the integration between DBCP and spring doesn't go down that well.

我们面临的问题是DBCP返回PoolableConnections对象,而Oracle期望OracleConnection对象。 (引发ClassCastException)

Problem that we face is that DBCP returns PoolableConnections Object while Oracle expects OracleConnection Objects. (Throws ClassCastException)

似乎已在Oracle 11g中处理此问题。但是我很好奇其他人如何使用Spring 10 for Oracle 10g(使用TOMCAT)实现Oracle连接池。

It seems that this problem has been handled in Oracle 11g. However I am curious as to how others have implemented Oracle connection pooling using spring framework for Oracle 10g (Using TOMCAT).

我们使用Ibatis作为ORM框架。

We use Ibatis as ORM framework.

我确信有办法。任何帮助表示赞赏。

I am sure there is a way. any help is appreciated.

推荐答案

我会使用Oracles提供的解决方案,它包含在他们的ojdbc jar中。较旧的方法是使用类 OracleConnectionPoolDataSource ,但现在您可以在常规 OracleDataSource 上设置参数并获取连接池。

I would use Oracles supplied solution, which in included in their ojdbc jars. The older way was with the class OracleConnectionPoolDataSource but now you can set a parameter on a regular OracleDataSource and get connection pooling.

以下是如何在Spring中执行此操作:

Here is how to do it in Spring:

<bean id="datasource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
   <property name="connectionCachingEnabled" value="true" />
   <property name="URL" value="${jdbc.url}" />
   ...all your connection properties
   <property name="connectionCacheProperties">
      <props merge="default">
         <prop key="MinLimit>3</prop>
         <prop key="MaxLimit">20</prop>
      </props>
   </property>
</bean>

这篇关于Oracle - 连接池与spring框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆