Problema de conexão do MySQL Hibernate enquanto estiver usando o c3p0

Eu tenho uma aplicação web desenvolvida com struts 1.3, Hibernate3 e Spring security. O aplicativo estava desativado anteriormente após 8 horas desde que o MySQL fechou a conexão após esse período. Então eu coleciono as informações de várias postagens para mantê-las vivas por muito tempo, agora são quase 20 - 24 horas. Alguém pode me ajudar a fazer essa coisa funcionar?

Sumário

Não consigo fazer login após 20 horas de inatividade. A conexão é fechada pelo MySQL.

Obrigado.

Encontre os trechos abaixo para a configuração do hibernate e c3p0.

Snippet de arquivo cfg de hibernação

    <property name="hibernate.dialect">se.etm.ewo.hibernate.CustomDialect</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">MY_JDBC_URL?autoReconnect=true</property>
    <property name="hibernate.connection.username">username</property>
    <property name="hibernate.connection.password">password</property>
    <property name="hibernate.connection.autoReconnect">true</property>
    <property name="hibernate.connection.autoReconnectForPools">true</property>
    <property name="hibernate.c3p0.idle_test_period">100</property>
    <property name="hibernate.c3p0.preferredTestQuery">select 1</property>
    <property name="hibernate.c3p0.testWhileIdle">true</property>
    <property name="hibernate.c3p0.testConnectionOnCheckout">true</property>
    <property name="hibernate.c3p0.min_size">10</property>
    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">true</property>

    <!-- Drop and re-create the database schema on startup -->
    <property name="hbm2ddl.auto">update</property>
    <property name="hibernate.current_session_context_class">thread</property>

Peça de configuração da mola

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />

    <property name="configLocation">
        <value>classpath:hibernate.cfg.xml</value>
    </property>
    <property name="hibernateProperties">
        <ref bean="hibernateProperties" />
    </property>
</bean>

<bean id="hibernateProperties"
    class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="ignoreResourceNotFound" value="true" />
    <property name="location">
        <value>classpath:hibernate.cfg.xml</value>
    </property>
</bean>

<!-- Data source -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close">
    <property name="driverClass">
        <value>com.mysql.jdbc.Driver</value>
    </property>
    <property name="jdbcUrl">
        <value>MY_JDBC_URL?autoReconnect=true</value>
    </property>
    <property name="user">
        <value>username</value>
    </property>
    <property name="password">
        <value>password</value>
    </property>
    <property name="initialPoolSize">
        <value>10</value>
    </property>
    <property name="maxPoolSize">
        <value>30</value>
    </property>
    <property name="minPoolSize">
        <value>10</value>
    </property>
    <property name="maxConnectionAge">
        <value>3600</value>
    </property>
    <property name="maxIdleTime">
        <value>3600</value>
    </property>
    <property name="maxIdleTimeExcessConnections">
        <value>1800</value>
    </property>
    <property name="acquireRetryAttempts">
        <value>3</value>
    </property>
    <property name="acquireRetryDelay">
        <value>3000</value>
    </property>
    <property name="breakAfterAcquireFailure">
        <value>false</value>
    </property>
    <property name="preferredTestQuery">
        <value>SELECT 1</value>
    </property>
    <property name="testConnectionOnCheckout">
        <value>true</value>
    </property>
</bean>
<bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>

Log C3p0

INFO AbstractPoolBackedDataSource: 462 - Inicializando o pool c3p0 ... com.mchange.v2.c3p0.ComboPooledDataSource [purchaseIncrement -> 3, PurchaseRetryAttempts -> 3, PurchaseRetryDelay -> 3000, autoCommitOnClose -> false, automaticTestTable -> , checkoutTimeout -> 0, connectionCustomizerClassName -> nulo, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1br9tik951qql1qj1z141xq | 2a868f36, debugUnreturned -, jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1br9tik951qql1qj1z141xq | 2a868f36, idleConnectionTestPeriod -> 0, initialPoolSize -> 10, jdbcUrl -: , maxAdministrativeTaskTime -> 0, maxConnectionAge -> 3600, maxIdleTime -> 3600, maxIdleTimeExcessConnections -> 1800, maxPoolSize -> 30, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, selectedTestQuery -> SELECT 1, propriedades -> {user = ******, senha = ******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> true, não retornadoConnectionTimeout -> 300, usa ProTraditionalReflectiveProxies -> false]

O log c3p0 parece exatamente essas linhas, não há nada relacionado ao problema. Você consegue encontrar alguma coisa?

questionAnswers(1)

yourAnswerToTheQuestion