jdbc4 CommunicationsException

Mam komputer z uruchomioną aplikacją java rozmawiający z instancją mysql działającą w tej samej instancji. aplikacja używa sterowników jdbc4 z mysql. Ciągle otrzymuję com.mysql.jdbc.exceptions.jdbc4.CommunicationsException w losowych czasach.

Oto cała wiadomość.

Nie można otworzyć połączenia JDBC dla transakcji; zagnieżdżonym wyjątkiem jest

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was25899 milliseconds ago.The last packet sent successfully to the server was 25899 milliseconds ago, which  is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

Dla mysql wartość global „wait_timeout” i „interactive_timeout” jest ustawiona na 3600 sekund, a „connect_timeout” jest ustawiona na 60 sekund. wartość limitu czasu oczekiwania jest znacznie wyższa niż 26 sekund (25899 ms). wspomniane w śledzeniu wyjątku.

Używam dbcp do zestawiania połączeń i tutaj jest konfiguracja spring bean dla źródła danych.

   <bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource" >
          <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
                    <property name="url" value="jdbc:mysql://localhost:3306/db"/>
                <property name="username" value="xxx"/>
                <property name="password" value="xxx" />
                    <property name="poolPreparedStatements" value="false" />
            <property name="maxActive" value="3" />
            <property name="maxIdle" value="3" />
    </bean>

Masz jakiś pomysł, dlaczego tak się dzieje? Czy użycie c3p0 rozwiąże problem?

questionAnswers(4)

yourAnswerToTheQuestion