Archive

Archive for August 27, 2009

Spring – Oracle Connection Pool Configuration

August 27, 2009 5 comments

Problem Statement: Configure Oracle Connection Pool in Spring

This is basic data source (Only testing)

<bean id="datasource1"
 class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
         <value>oracle.jdbc.driver.OracleDriver</value>
    </property>
<property name="url">
         <value>ORACLE URL</value>
    </property>
<property name="username">
         <value>user id</value>
    </property>
<property name="password">
         <value>user password</value>
    </property>
</bean>

This is dbcp data source (Preferred for Testing.)

<bean id="datasource2"
 class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
         <value>org.apache.commons.dbcp.BasicDataSource</value>
    </property>
<property name="url">
         <value>ORACLE URL</value>
    </property>
<property name="username">
         <value>user id</value>
    </property>
<property name="password">
         <value>user password</value>
    </property>
<property name="initialSize" value="5"/>
<property name="maxActive" value="20"/>
</bean>

This is Oracle Connection Pool (Production Quality)


<bean id="connectionPool1" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
<property name="connectionCachingEnabled" value="true" />
<property name="URL">
         <value>ORACLE URL</value>
    </property>
<property name="user">
         <value>user id</value>
    </property>
<property name="password">
         <value>user password</value>
    </property>
<property name="connectionCacheProperties">
      <value>
		MinLimit:1
		MaxLimit:5
		InitialLimit:1
		ConnectionWaitTimeout:120
		InactivityTimeout:180
		ValidateConnection:true
      </value>
   </property>
</bean>

Oracle Connection Pool is better than DBCP and C3P0
http://www.lambdaprobe.org/d/oracle.shtml

-o-

Follow

Get every new post delivered to your Inbox.