Pages

Thursday, September 24, 2009

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException

I have noticed this error in my MySql Outage, suddenly going down due to overload.
after my observation I found that this kind of error mostly will cause because of
system variables settings of wait_timeout and interactive_timeout on mysql server is set lower than datasource
idle timeout period.
my datasource pooling property for conection time out is set to 1 min
on server variable wait_timeout is set to 28 sec. (28800 milisec)

in most cases where connection is idle from host and if server wait_timeout is less than client datasource timeout
server closes connection after its sleep time is more than wait_timeout or interactive_timeout period. and client is unaware of this
and when he fires query again on same connection gets above error.

to avoid this there are following ways
1. if you are using plain connection using jconnector set autoconnect property to true.
2. if you have custom connection poolilng machanism try to validate your connection before using it from pool.
3. in other case try to set your server variable values for wait_timeout, interactive_timeout greater than your datasource timeout.

No comments:

Post a Comment