Announcement Announcement Module
No announcement yet.
C3P0/Spring - Idle Connections not used Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • C3P0/Spring - Idle Connections not used


    I am a newbie in C3P0/Spring and I have a problem that I couldn't yet figure out.

    In my java program I have a thread that run eternally in a loop. Inside the loop, at every 5 minutes I do a search in DB. But in each search a new connection is created in the database, and Idle connections is never used.

    Because this in a given time I get some problems in my application.

    Why the idle connections is not used ?

    Thanks in advance.

    Kleyson Rios.

    -----> My application log:
    Running wall: Thu Jan 24 11:18:39 BRST 2013
    Running wall: Thu Jan 24 11:23:40 BRST 2013
    Running wall: Thu Jan 24 11:28:40 BRST 2013
    Running wall: Thu Jan 24 11:33:40 BRST 2013
    Running wall: Thu Jan 24 11:38:40 BRST 2013

    -----> Connections in the Postgres
    "query_start";"state_change";"waiting";"state";"qu ery"
    "2013-01-24 11:18:40.33696-02";"2013-01-24 11:18:40.337243-02";f;"idle";"select dmcontrol0 ..."
    "2013-01-24 11:23:40.430089-02";"2013-01-24 11:23:40.430398-02";f;"idle";"select dmcontrol0 ..."
    "2013-01-24 11:28:40.529697-02";"2013-01-24 11:28:40.529971-02";f;"idle";"select dmcontrol0 ..."
    "2013-01-24 11:33:40.622764-02";"2013-01-24 11:33:40.623075-02";f;"idle";"select dmcontrol0 ..."
    "2013-01-24 11:38:40.721462-02";"2013-01-24 11:38:40.721746-02";f;"idle";"select dmcontrol0 ..."

    -----> My spring.xml
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotati on.AnnotationSessionFactoryBean">
    <property name="dataSource">
    <ref local="dataSource" />
    <property name="hibernateProperties">
    <prop key="hibernate.show_sql">false</prop>
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
    <prop key="hibernate.format_sql">true</prop>
    <prop key="">update</prop>
    <prop key="hibernate.cache.provider_class">org.hibernate .cache.EhCacheProvider</prop>
    <prop key="hibernate.generate_statistics">true</prop>
    <prop key="hibernate.cache.use_query_cache">true</prop>
    <prop key="hibernate.auto_close_session">true</prop>
    <property name="annotatedClasses">

    <bean id="dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="${hibernate.connection.driver_class}" />
    <property name="jdbcUrl" value="${hibernate.connection.url}" />
    <property name="user" value="${hibernate.connection.username}" />
    <property name="password" value="${hibernate.connection.password}" />
    <!-- these are C3P0 properties - c3p0 config -->
    <property name="acquireIncrement" value="2" />
    <property name="minPoolSize" value="2" />
    <property name="maxPoolSize" value="10" />
    <property name="maxStatements" value="50" />
    <property name="maxIdleTime" value="1800" /> <!-- seconds -->
    <property name="idleConnectionTestPeriod" value="180" /> <!-- seconds -->

  • #2
    Please use [ code][/code ] tags when posting code/xml/stacktraces that way it remains readable.

    Without a proper transaction setup sessions and connections will remain until they timeout judging by your symptoms and configuration there is nothing that drives the transaction.