I saw the errors 'The last packet successfully received from the server was x milliseconds ago' and 'Communications link failure' a lot lately. So much it almost drove me crazy. I knew it had something to do with the timeout of 8 hours that MySQL has by default for every connection.This is a simple problem, but the internet is so polluted with everybody parroting each other that it didn't get me any further. After a few days I fixed the problem, it was indeed very simple but because I did something stupid with JPA it became very complex. In this article I'll explain the simple solution and tell you about my complex problem, maybe you're having the same trouble.