Spring + DBCP

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" destroy-method="close">
  <property name="driverClassName">
  <property name="url">
  <property name="username">
  <property name="password">
  <property name="initialSize">
  <property name="maxActive">
  <property name="maxIdle">

There are more options that can be used to configure the DBCP connection pool,
eg whether to test connections when getting from the pool or the time to wait
before getting a connection. The complete list of options is given


  1. Thanks, just what I needed!

  2. Wilfred said

    When I repeat the process of compiling and re-running my web application a few number of times, the application hangs up and fails to run. And the Tomcat container cannot be stopped normally. If I stop using dbcp, this never happens no matter how many times I re-compile and re-run the application. Do anyone encounter this before? Thank you!

  3. ifnu said

    you need to add these properties :


  4. Hi there colleagues, nice paragraph and pleasant urging commented here, I am really enjoying by these.

  5. When I originally commented I clicked the “Notify me when new comments are added” checkbox
    and now each time a comment is added I get
    four e-mails with the same comment. Is there any way you can remove me from
    that service? Cheers!

  6. webpage said

    Great goods from you, man. I have take into accout your stuff previous to and you are just
    extremely great. I really like what you’ve obtained right here, really like what you are stating and the way wherein you are saying it. You are making it entertaining and you still take care of to keep it smart. I can’t
    wait to learn far more from you. That is really a great site.

  7. When someone writes an article he/she keeps the thought of a user in his/her brain
    that how a user can know it. So that’s why this paragraph is great. Thanks!

  8. website said

    It is the best time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I want
    to suggest you few interesting things or advice. Maybe
    you could write next articles referring to this
    article. I desire to read even more things about it!

  9. Turbo Jam said

    I’m not that much of a internet reader to be honest but your blogs really
    nice, keep it up! I’ll go ahead and bookmark your website to come back down the road. Many thanks

  10. What’s up, this weekend is fastidious in support of me,
    for the reason that this time i am reading this enormous informative article here at
    my home.

  11. Byron said

    I don’t even know how I stopped up here, however I believed this submit was great.

    I don’t recognise who you are but certainly you are going to a famous blogger if you happen to aren’t already.

  12. Robby said

    When it comes to high-class hotels, Las Vegas is unquestionably the best place you can
    look with awe. This is one area most people will never reach experience in their lifetime.

    Also various Las Vegas hotels can give you some packages that are
    integrated within their plans for couples only.

  13. Hello, I want to subscribe for this webpage to get hottest updates,
    therefore where can i do it please assist.

  14. Hi i am kavin, its my first occasion to commenting anyplace, when i read
    this article i thought i could also make comment due
    to this sensible piece of writing.

  15. Very rapidly this site will be famous amid all blog visitors, due to it’s good articles

  16. Thanks for sharing such a good idea, article is nice, thats why i have
    read it completely

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: