/ / jdbc4.CommunicationsException - timeout misterioso - java, mysql, jdbc, c3p0

jdbc4.CommunicationsException - timeout misterioso - java, mysql, jdbc, c3p0

Testo completo del messaggio di log:

Log Message: An error occurred while grabbing new users com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 44,567,434 milliseconds ago. The last packet sent successfully to the server was 44,567,434 milliseconds ago. 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.

Questo è strano per me perché è più di 10ore. Il mio programma ha funzionato felicemente e con successo, inclusa la comunicazione con il database, nelle ultime 10 ore. La migliore ipotesi che ho è che una singola connessione nel pool fosse obsoleta, ma in quel caso non so perché questo non sarebbe stato ripulito automaticamente o se questa eccezione fosse correlata a quell'operazione. Come dovrei gestirlo?

Sto usando il pool di connessione c3p0.

risposte:

1 per risposta № 1

c3p0 ha molti mezzi per testare Connections eimpedendo loro di scadere o di andare stantio. il modo più semplice per risolvere il problema specifico che si sta vedendo sarebbe semplicemente impostare il parametro di configurazione maxIdleTime su, per esempio, 8 ore (28800 secondi).

ma potresti voler iniziare a testare le connessioni in generale, ad esempio impostando il periodo idleConnectionTest su qualcosa di frequente e impostando testConnectionOnCheckin su true. Vedere...

http://www.mchange.com/projects/c3p0/#configuring_connection_testing

http://www.mchange.com/projects/c3p0/#configuration_properties