Announcement Announcement Module
Collapse
No announcement yet.
c3p0 connection management problems Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • c3p0 connection management problems

    Hi,

    I'm using Spring 3.0.2, Hibernate 3.5.0 and c3p0 0.9.1.2 and I'm having a ton of errors when it comes down to retrieving connections and commiting transactions. Here's my configuration of c3p0:

    Code:
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
            <property name="driverClass" value="${jdbc.driverClassName}"/>
            <property name="jdbcUrl" value="${jdbc.url}"/>
            <property name="properties">
                <props>
                    <prop key="c3p0.acquireIncrement">5</prop>
                    <prop key="c3p0.maxIdleTime">30</prop>
                    <prop key="c3p0.idleConnectionTestPeriod">20</prop>
                    <prop key="c3p0.maxPoolSize">100</prop>
                    <prop key="c3p0.maxStatements">0</prop>
                    <prop key="c3p0.minPoolSize">1</prop>
                    <prop key="user">${jdbc.username}</prop>
                    <prop key="password">${jdbc.password}</prop>
                </props>
            </property>
        </bean>
    Up until recently I got this error pretty often:
    Code:
    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
    Last packet sent to the server was 0 ms ago.
    Recently I also get these:
    Code:
    com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Connection.close() has already been called. Invalid operation in this state.
    java.sql.SQLException: Connections could not be acquired from the underlying database!
    Any suggestions?

  • #2
    Property incorrectly configured, try this...

    <bean id="dataSource"
    class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close">

    <property name="driverClass"><value>${jdbc.driverClassName}</value></property>
    <property name="jdbcUrl"><value>${jdbc.url}</value></property>
    <property name="user"><value>${jdbc.username}</value></property>
    <property name="password"><value>${jdbc.password}</value></property>

    <property name="initialPoolSize"><value>3</value></property>
    <property name="minPoolSize"><value>3</value></property>
    <property name="maxPoolSize"><value>50</value></property>
    <!-- <property name="timeout"><value>0</value></property> --> <!-- 0 means: no timeout -->
    <property name="idleConnectionTestPeriod"><value>200</value></property>
    <property name="acquireIncrement"><value>1</value></property>
    <property name="maxStatements"><value>0</value></property> <!-- 0 means: statement caching is turned off. -->
    <property name="numHelperThreads"><value>3</value></property> <!-- 3 is default -->

    </bean>

    Comment

    Working...
    X