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 4266150
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:43:16+00:00 2026-05-21T06:43:16+00:00

I learned that to configure c3p0 pooling in hibernate, we can have write the

  • 0

I learned that to configure c3p0 pooling in hibernate, we can have write the configuration in hibernate.cfg.xml such this:

<property name="hibernate.c3p0.min_size">2</property>
    <property name="hibernate.c3p0.max_size">5</property>
    <property name="hibernate.c3p0.timeout">600</property>
    <property name="hibernate.c3p0.max_statements">0</property>
    <property name="hibernate.c3p0.idle_test_period">300</property>
    <property name="hibernate.c3p0.acquire_increment">1</property>

However I configured Hibernate using Spring. When I tried to do below, it wouldn’t work:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost/news_loader" />
    <property name="username" value="blah" />
    <property name="password" value="blah" /> 

    <property name="hibernate.c3p0.min_size" value="2" />
    <property name="hibernate.c3p0.max_size" value="5" />
    <property name="hibernate.c3p0.timeout" value="600" />
    <property name="hibernate.c3p0.max_statements" value="0" />
    <property name="hibernate.c3p0.idle_test_period" value="300"/>
    <property name="hibernate.c3p0.acquire_increment" value="1" />
</bean>

I’ve read about using the stand-alone c3p0 pooling which can be configured using Spring, but is there any way that I can configure the built-in c3p0 pooling in Hibernate using Spring?

Enlighten me coz i’m a beginner.

  • 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-05-21T06:43:17+00:00Added an answer on May 21, 2026 at 6:43 am

    Here is a sample configuration (from our application) on how to configure c3p0 in the datasource:

    <bean id="dataSourceGlobal" class="com.mchange.v2.c3p0.ComboPooledDataSource"
              destroy-method="close">
            <property name="driverClass" value="${driver}" />
            <property name="jdbcUrl" value="${server}" />
            <property name="user" value="${user}" />
            <property name="password" value="${passw}" /> 
    
            <!-- these are C3P0 properties -->
            <property name="acquireIncrement" value="${acquireIncrement}" />
            <property name="minPoolSize" value="${minPoolSize}" />
            <property name="maxPoolSize" value="${maxPoolSize}" />
            <property name="maxIdleTime" value="${maxIdleTime}" />
    </bean>
    

    We use an external property file to configure some parameters, but they can be configured directly in Spring too.

    If you want hibernate to take care of the pooling, then you need to configure the Session properties:

    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
        <!--suppress InjectionValueTypeInspection -->
        <property name="mappingResources" ref="hibernateMappingList" />
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
                <prop key="transaction.factory_class">
                    net.sf.hibernate.transaction.JDBCTransactionFactory
                </prop>
                <prop key="hibernate.transaction.factory_class">
                    net.sf.hibernate.transaction.JDBCTransactionFactory
                </prop>
                <prop key="hibernate.show_sql">false</prop>
                <prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
                <prop key="hibernate.jdbc.batch_size">0</prop>
    
                <prop name="hibernate.c3p0.min_size" value="2" />
                <prop name="hibernate.c3p0.max_size" value="5" />
                <prop name="hibernate.c3p0.timeout" value="600" />
                <prop name="hibernate.c3p0.max_statements" value="0" />
                <prop name="hibernate.c3p0.idle_test_period" value="300"/>
                <prop name="hibernate.c3p0.acquire_increment" value="1" />
          </props>
        </property>
    </bean>
    

    You must use one of the approaches: either pool at the datasource or pool at the hibernate Session. Never use both, as it wastes resources.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I learned that Xcode can compile c code, that means can we write whole
I learned that in pyparsing, you can name an element/group/node by doing this: token
I have learned that in a class you can declare variables and methods. They
I've learned that MySQL can compress communication between servers and clients. Compression is used
I recently learned that all stl containers have swap function: i.e. c1.swap(c2); will lead
I have learned that Windows uses UTF-16LE on x86/x64 systems. What about Linux? Which
When I learned CGI I learned that any programing language can be used to
I have learned that Python 3 is not backwards compatible. Will it not affect
I've just learned that we can iterate through all checkboxes in a document, but
I've learned that Xor operation can be used to implement effective swap function. like

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.