Search code examples
javajdbcc3p0

Connection is invalid in connection pooling


I am using c3p0 for connection poolingin my java application. We write the all properties related to it and i am having wait_timeout value is 60. We can not increase wait_timeout value. I got error "connection is invalid". How to handle this error.


Solution

  • you should set max_idle_time for waiting timeout ; for example :

    <property name="hibernate.c3p0.min_size">5</property>
    <property name="hibernate.c3p0.max_size">50</property>
    <property name="hibernate.c3p0.timeout">15</property>
    <property name="hibernate.c3p0.max_idle_time">60</property>
    <property name="hibernate.c3p0.max_statements">50</property>
    <property name="hibernate.c3p0.idle_test_period">10</property> 
    

    see this link : http://www.mchange.com/projects/c3p0/index.html#configuration_files

    you can find same question in stack overflow fro example :

    Hibernate c3p0 connection pool not timing out idle connections

    c3p0 maxIdleTime is same as wait_timeout of mysql?