0

I seem to have a problem, where I get a communications exception when I try to write to the database. It seems to happen after a perioid of inactivity, but I'm not sure.

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 40,404,396 milliseconds ago.  The last packet sent successfully to the server was 40,404,396 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.

I tried to set the timeout higher, and added autoReconnect=true to the connection string. When the exception is thrown, it does retry 4 times, and then stops.

The fun thing is, that the database is located within the same server as the application-server. How come this happens, and how do I fix this?

I really hope you guys can help me!

Best regards, Ben

EDIT As pointed out, this questions is seen multiple places. Unfortunately the proposed solutions didn't help me. Either they had an actual communications failure (Not running mysql local on the server) or they fixed it with another connection string. I've tried all that was said, and still getting the error. Latest error from the weekend is shown here: http://pastebin.com/wMb7Ygwd

Benjamin Larsen
  • 345
  • 2
  • 15
  • Possible duplicate of [jdbc4 CommunicationsException](http://stackoverflow.com/questions/1152124/jdbc4-communicationsexception) – Mark Rotteveel Oct 14 '16 at 07:14
  • Thanks - one of the questions I haven't seen before. I really tried getting through all, but couldn't find a solution. Though unfortunately I don't use dbcp for connection pooling. :( – Benjamin Larsen Oct 14 '16 at 07:17
  • what timeout did you set higher? More info is needed concerning your connection pool environment. – Drew Oct 14 '16 at 07:20
  • Most connection pools have similar features, you just need to find that feature. – Mark Rotteveel Oct 14 '16 at 07:20
  • @Drew - the wait_timeout. I'm using a Glassfish Pool. The settings are as follows: 1: http://tinypic.com/r/10zo849/9 2: http://tinypic.com/r/qye6us/9 (1) 2: http://tinypic.com/r/2vabkva/9 (2) 3: http://tinypic.com/r/8wefxg/9 – Benjamin Larsen Oct 14 '16 at 07:37
  • is [This](http://stackoverflow.com/a/26160767) useful? There are only 2 other glassfish related seen here. – Drew Oct 14 '16 at 07:44
  • Hi @Drew! I tried adding the socketTimeout and set the system to work over the weekend. Unfortunaly it did not have an effect - it still got the same error. See log: http://pastebin.com/wMb7Ygwd. I really hope you can help me! :) – Benjamin Larsen Oct 16 '16 at 19:37
  • I'll point some people at your question from another chat room. Kind of tied up at the moment – Drew Oct 16 '16 at 19:54
  • Thanks @Drew! I've added some code of the DAO on the oracle community if that helps. https://community.oracle.com/message/14070865#14070865 – Benjamin Larsen Oct 17 '16 at 05:14
  • sorry I havent been of much help. I posted a quick link [here](http://chat.stackoverflow.com/transcript/41570?m=33519280#33519280) and will circle back to this soon. – Drew Oct 17 '16 at 05:19
  • Please take a look at [this](http://stackoverflow.com/questions/6865538/solving-a-communications-link-failure-with-jdbc-and-mysql), might help! – N00b Pr0grammer Oct 17 '16 at 09:29

0 Answers0