ePrivacy and GPDR Cookie Consent by Cookie Consent Spring connection Pooling With DBCP - Develop In Java
Develop In Java
All things Java and development

Spring connection Pooling With DBCP

Recently I wanted to add a connection pool to my Spring Web Application. I decided to use Commons DBCP to provide the connection pool as I’m using the Spring JDBC wrapper classes. Googling around didn’t find any examples of how to set up DBCP, so I’ve written my findings here.

Adding a connection pool to a Spring app is simply a matter of specifying the relevant entries in the Spring servlet configuration file. The XML snippet below shows an example of how a database connection pool can easily be configured.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
  <property name="driverClassName">

  <property name="url">
  <property name="username">

  <property name="password">
  <property name="initialSize">

  <property name="maxActive">

  <property name="maxIdle">


Photo by Raphaël Biscaldi on Unsplash