Are you using a connection pool? If so, make sure you advise your connection pool to test connections before handing them out of the pool. This is necessary with MySQL because it aggressively closes idle connections and since connections in a connections pool are mostly chilling, they are broken after a while and without any notice.