jdbc – Spring JdbcTemplate ConnectionPooling Configuration – Education Career Blog

I am working on a Spring MVC application in which I have recently been convinced to revamp my database code. Before I was using very traditional JDBC code that I have been told was very “old school” because of the boilerplate code. I have been making the transition to using JdbcTemplate with Spring.

I have configured a bean like shown below in my applicationContext.xml file.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:ip-address:port/dbName"/>
    <property name="username" value="myUsername"/>
    <property name="password" value="mypassword"/>

I have run tests just to make sure everything is working and it is.

My question is, I am aware that I am using the Commons DBCP package which uses the
following packages

 commons-dbcp package
 commons-pool package

Again, I am very inexperienced with this, so I apologize if I am mis referencing something or am explaining something incorrectly.

I have followed what most of the tutorials have said to do and specified a jdbcTemplate and injected the dataSource bean into it, but this doesnt really refer to my question.

What I would really like to know is, am I using ConnectionPooling with this configuration?

If so, is it being done behind the scenes, or do I need to specify to do it somewhere?

I have looked at the documentation at Here which gives the following, but I am not sure exactly how to interpret it.

“here are several Database Connection Pools already available, both within Apache products and elsewhere. This Commons package provides an opportunity to coordinate the efforts required to create and maintain an efficient, feature-rich package under the ASF license.
The commons-dbcp package relies on code in the commons-pool package to provide the underlying object pool mechanisms that it utilizes.”

I also looked at the Configuration Page

and based on this page, I would think that I am able to do ConnectionPooling, but may need to specify additional parameters in my dataSource bean.

Can somebody please answer my questions or point me in the right direction?


Yes you are using connection pooling.

here is another thread you might find interesting


Also most of the links you specified above will provide additional information on parameters that can be set.

Leave a Comment