Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8715989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:58:19+00:00 2026-06-13T05:58:19+00:00

I was wondering if I can run multiple c3p0 datasources for one DB, something

  • 0

I was wondering if I can run multiple c3p0 datasources for one DB, something like:

<bean id="dataSource1" class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="${db.driverClassName}"/>
    <property name="jdbcUrl" value="${db.url}/schema1"/>
    <property name="user" value="${db.username}"/>
    <property name="password" value="${db.password}"/>

    <property name="acquireIncrement" value="1" />
    <property name="idleConnectionTestPeriod" value="100"/>
    <property name="minPoolSize" value="5" />
    <property name="maxPoolSize" value="50" />
    <property name="maxIdleTime" value="1800" />
</bean>

<bean id="dataSource2" class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="${db.driverClassName}"/>
    <property name="jdbcUrl" value="${db.url}/schema2"/>
    <property name="user" value="${db.username}"/>
    <property name="password" value="${db.password}"/>

    <property name="acquireIncrement" value="1" />
    <property name="idleConnectionTestPeriod" value="100"/>
    <property name="minPoolSize" value="5" />
    <property name="maxPoolSize" value="50" />
    <property name="maxIdleTime" value="1800" />
</bean>

They will be used by difference persistence services.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:58:20+00:00Added an answer on June 13, 2026 at 5:58 am

    That’s absolutely fine. You’ll run into some configuration issues like:

    • autowiring DataSource by type won’t work

    • @Transactional/declarative transactions will work only against one, selected DataSource. Alternatively you’ll have to manually tell which transaction manager you want to use (thus you’ll need two transaction managers as well: transactionManager1 and transactionManager2):

      @Transactional("transactionalManager2")
      

    Besides, there’s nothing wrong with this configuration. Actually it’s a pretty good idea (+1): if some layers/components of your application saturate the pool, others can still operate.

    The only thing I recommend is to use lesser known abstract/parent bean declarations to avoid repetition:

    <bean id="dataSource" abstract="true" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
        <property name="driverClass" value="${db.driverClassName}"/>
        <property name="user" value="${db.username}"/>
        <property name="password" value="${db.password}"/>
        <property name="acquireIncrement" value="1" />
        <property name="idleConnectionTestPeriod" value="100"/>
        <property name="minPoolSize" value="5" />
        <property name="maxPoolSize" value="50" />
        <property name="maxIdleTime" value="1800" />
    </bean>
    
    <bean id="dataSource1" parent="dataSource">
        <property name="jdbcUrl" value="${db.url}/schema1"/>
    </bean>
    <bean id="dataSource2" parent="dataSource">
        <property name="jdbcUrl" value="${db.url}/schema2"/>
    </bean>
    

    See also:

    • What is meant by abstract="true" in spring?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I was wondering, Heroku can run multiple dynos to handle a growing number
I am new to ninject, I am wondering how I can run custom initizlisation
Just wondering is it possible to build CLI app that can be run from
I was wondering how can I do something similar to Facebook when a link
I need to run multiple commands in sequence using NSTask and was wondering what
i was wondering if there's a way to build a class which can accept
Wondering if it's possible to do something like the following (I know the code
I was wondering if it's possible to run a script for multiple Clients where
was wondering how can I create a sub drop down box upon selecting a
I was wondering how can I track the current logged in user in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.