Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 498
Sekhar Avatar asked Mar 21 '12 12:03

Sekhar


1 Answers

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.

like image 101
Arnaud Gourlay Avatar answered Nov 01 '22 14:11

Arnaud Gourlay