4

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.

Stewart
  • 17,616
  • 8
  • 52
  • 80
Sekhar
  • 961
  • 5
  • 15
  • 27

1 Answers1

12

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.

Daniel Serodio
  • 4,229
  • 5
  • 37
  • 33
Arnaud Gourlay
  • 4,646
  • 1
  • 29
  • 35
  • hi shagaan , thanks alot , but is there any optimum value principle to be followed while applying these 3 settings ? – Sekhar Mar 21 '12 at 13:22
  • 2
    It depends on the number of concurrent access you have on your database. I don't know any optimum value as it is very specific to every application. If you have performance trouble, monitor your application, you will quicly see if your threads are fighting to get a db connection. In that case increase it. – Arnaud Gourlay Mar 21 '12 at 13:36