“Communications link failure” error on MySQL using JDBC after the program has run for 38 hrs. Another program on the same machine hitting the same server (also java) continues to run. Both are using the exact same java code to access the server, as do the java programs running on 4 other machines at the same time. I get this error randomly on different machines, after a program has been running successfully (reads/inserts/updates to the database) for quite a while. The error includes the first line above the stack trace:
The last packet successfully received from the server was n milliseconds ago. where n has varied between 0 and 25.
I might suspect that the server has run out connections to hand out, but I get a totally different error when that happens (I encountered it and updated my server to increase max connections, which eliminated that error). I get the error whether I use c3p0 to pool connections, or not.
Please read before flagging as a duplicate. The connect string and database are fine, as it worked for 38 hours (and continues to work in other processes on the same machine and different machines accessing the same MySQL server) using exactly the same java code. This is a transient/random error. If I simply restart the program, it continues successfully. I would say it's OS related, except that it occurs on both Windows and Mac OS X. Which leads me to believe it's likely something going on in the java VM.