Oracle - merging connections with spring infrastructure

We are trying to implement the Oracle connection pool using the Spring Framework. We use the DBCP join join method. However, the integration between DBCP and Spring is not so good.

The problem we are facing is that DBCP returns a PoolableConnections object, while Oracle expects OracleConnection Objects. (Throws a ClassCastException)

It seems that this problem has been resolved in Oracle 11g. However, I am curious how others have implemented the Oracle connection pool using the Spring framework for Oracle 10g (using TOMCAT).

We use Ibatis as an ORM structure.

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

+2
source share
5

, , ojdbc. OracleConnectionPoolDataSource, OracleDataSource .

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>
+15

C3PO . . bean , . com.mchange.v2.c3p0.ComboPooledDataSource( ) spring. , spring (DriverManagerDataSource), , .

spring.

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:XE"/>
    <property name="user" value="username"/>
    <property name="password" value="secret"/>
    <property name="minPoolSize" value="5"/>
    <property name="maxPoolSize" value="20"/>
    <property name="acquireIncrement" value="1"/>
    <property name="idleConnectionTestPeriod" value="100"/>
    <property name="maxStatements" value="0"/>
    <property name="checkoutTimeout" value="60000"/>

Spring dataSource bean Hibernate, . jar c3pO ...

+4

, , . Tomcat , , Tomcat ORM ( Tomcat, ).

, Spring, , .

Tomcat, , :

, Tomcat DBCP, JNDI, ( - , dev - , WebSphere, WebLogic ..).

+3

SimpleNativeJdbcExtractor CommonsDbcpNativeJdbcExtractor, . .

, Connections, , SimpleNativeJdbcExtractor. (, DBCP Jakarta Commons) JDBC, : NativeJdbcExtractor (, CommonsDbcpNativeJdbcExtractor).

Click here [http://static.springsource.org/ spring / docs / 2.0.x / api / org / springframework / jdbc / support / nativejdbc / NativeJdbcExtractor.html]

0
source

I also ran into the same problem as you .. so I used the Oracle Native connection pool .. it runs smoothly.

here is the link for details http://www.lambdaprobe.org/d/oracle.shtml

Thank! Pratik

-1
source

All Articles