Sekhar
Sekhar

Reputation: 1001

How to set the max pool size or connection size for BasicDataSource in Spring Framework

I have a Spring application deployed in JBoss EAP server, using the following settings:

<bean:bean id="userDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <bean:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
    <bean:property name="url" value="jdbc:oracle:thin:@10.8.1.5:1521:DB"/>
    <bean:property name="username" value="WEBDB"/>
    <bean:property name="password" value="WEBDB"/>
</bean:bean>

How do I configure the connection pool's min and max size?

Any references or any best practices for BasicDataSource will be of great help.

Upvotes: 4

Views: 31812

Answers (1)

Arnaud Gourlay
Arnaud Gourlay

Reputation: 4666

You could add to your userDataSource the appropriate properties, for example:

<bean:property name="initialSize" value="1" />
<bean:property name="maxActive"   value="5" />
<bean:property name="maxIdle"     value="2" />

See https://commons.apache.org/proper/commons-dbcp/configuration.html for reference.

Upvotes: 12

Related Questions