title: The last packet sent successfully to the server was 79,547 milliseconds ago. is longer than the server configured value of 'wait_timeout'
body: <p>I have a big problem and I do not know how to fix it:</p>
  
  <p>I have a singleton instance of the database as follow:</p>
  
  <pre><code>public Connection getConnection() throws SQLException {
      if (db_con == null)
          db_con = createConnection();
  
      return db_con;
  }
  </code></pre>
  
  <p>And I have a code that as follow:</p>
  
  <pre><code>   shortTextScoringComponent.scoreComponent(    "RS",SelectDataBase.getBlogs(rightSarcastic));
      shortTextScoringComponent.scoreComponent( "RNS",SelectDataBase.getBlogs(rightNonSarcasm));
      shortTextScoringComponent.scoreComponent( "FNS",SelectDataBase.getBlogs(wrongNonSarcasm));
      shortTextScoringComponent.scoreComponent( "FS",SelectDataBase.getBlogs(wrongSarcasm));
  </code></pre>
  
  <p>So as you can see I call the database 4 times and it is note worthy that between each call there is a long time of processing so after he second line is performed successfuly I mean this line:</p>
  
  <pre><code>SelectDataBase.getBlogs(rightNonSarcasm);
  </code></pre>
  
  <p>when it comes to the third line I get the following error:</p>
  
  <pre><code>com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet    successfully received from the server was 79,547,948 milliseconds ago.  The last packet sent successfully to the server was 79,547,964 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.
  
     com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No     operations allowed after connection closed.
  </code></pre>
  
  <p>I searched a lot but there are many different answers which confuses me, do you have any idea what my exact problem is?</p>