title: Spring JDBC connection pool best practices
body: <p>I have a basic Spring JDBC application with a pretty basic configuration:</p>
  
  <pre><code>&lt;bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
     &lt;property name="driverClassName" value="oracle.jdbc.OracleDriver"/&gt;
     &lt;property name="url" value="jdbc:oracle:thin:@1.1.1.1:1521:XXX"/&gt;
     &lt;property name="username" value="username"/&gt;
     &lt;property name="password" value="password"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dbThing" class="com.DbThing"&gt;
     &lt;property name="dataSource" ref="myDataSource"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I would like to introduce a connection pool, and after reading several threads on SO I am a bit confused about which pooling library to use.</p>
  
  <p>The libraries that seem to have more credits on SO are <a href="http://www.mchange.com/projects/c3p0/index.html" rel="noreferrer">C3P0</a> and <a href="http://commons.apache.org/dbcp/" rel="noreferrer">DBCP</a>. Since I'm using Oracle, I could also use the <a href="https://stackoverflow.com/questions/777372/spring-connection-pooling/2041171#2041171">pooled data source</a> offered by the driver.</p>
  
  <p>I understand that there are more libraries available - for instance the new Apache Tomcat 7 pooling libraries.</p>
  
  <p>Is there any library that I should really avoid? </p>
  
  <p>Is there any recommended configuration I should use with a given library?</p>
  
  <p>Any "war story" you care to share?</p>