List:Cluster« Previous MessageNext Message »
From:Hartmut Holzgraefe Date:March 9 2010 7:51am
Subject:Re: Application lost database connection
View as plain text  
Manasi Save wrote:
> Hi All,
> I am really not sure whether this question should be asked here or not 
> but I am hoping that someone must have faced this problem.
> My Servers are losing connections with database because of inactivity 
> and on next activity I am getting following error :- 
> "The last packet successfully received from the server was40939 seconds 
> ago.The last packet sent successfully to the server was 40939 seconds 
> ago, which  is longer than the server configured value of 
> 'wait_timeout'. 

the server will disconnect idle client connections after wait_timeout
seconds to protect its resources:

A client idle that long is considered to be either dead or at least
not using the database actively in any way, so that it won't get
hurt by the little extra cost to reestablish the connection ...

> 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."
> Do I need to change in the application for this or what changes do I 
> need to do to fix this error.

the error message should have given you the different ways to deal
with this already?

  * server side:

    ** configure wait_timeout to a higher value

  * application side:

    ** test connection validity before using it, reopening it
       manually as needed

    ** add connection property 'autoReconnect=true' to have
       the MySQL Java connector deal with this automatically

Hartmut Holzgraefe, MySQL Regional Support Manager, EMEA

Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten
Amtsgericht München: HRB 161028
Geschäftsführer: Thomas Schröder, Wolfgang Engels
Vorsitzender des Aufsichtsrates: Martin Häring