Z
Z
Zaur Abdulgalimov2016-09-04 21:07:08
MySQL
Zaur Abdulgalimov, 2016-09-04 21:07:08

Why can't hibernate autoconnect to mysql after a timeout?

Good afternoon!
After a certain downtime, my connection to mysql through hibernate falls off. These are the hibernate settings I use:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM "http://www.hbernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://hostname?useUnicode=true&amp;characterEncoding=UTF-8</property>
        <property name="hibernate.connection.username">username</property>
        <property name="connection.password">password</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
        <property name="hibernate.jdbc.batch_size">30</property>
        <property name="hibernate.current_session_context_class">thread</property>

        <property name="hibernate.c3p0.minPoolSize">5</property>
        <property name="hibernate.c3p0.maxPoolSize">20</property>
        <property name="hibernate.c3p0.timeout">180000</property>
        <property name="hibernate.c3p0.max_statement">50</property>

        <property name="connection.autoReconnect">true</property>
        <property name="connection.autoReconnectForPools">true</property>
        <property name="connection.is-connection-validation-required">true</property>

        <mapping class="package.name.ClassName"/>

    </session-factory>
</hibernate-configuration>

Please tell me what I'm doing wrong and how to fix it?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
parkito, 2016-09-05
@abdulgalimov

<property name="hibernate.c3p0.timeout">180000</property>

Try
<property name="hibernate.c3p0.timeout">0</property>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question