2015-12-27 4 views
6

のサーバー構成されている値よりもサーバーに最後に送信されたパケットは、79,547ミリ秒前に送信されました。</p> <p>私は次のようにデータベースのシングルトンインスタンスを持っている:私は大きな問題を抱えていると私はそれを修正するのか分からないが「WAIT_TIMEOUT」

public Connection getConnection() throws SQLException { 
    if (db_con == null) 
     db_con = createConnection(); 

    return db_con; 
} 

あなたは私がデータベースを4回呼び出して見ることができるように

shortTextScoringComponent.scoreComponent( "RS",SelectDataBase.getBlogs(rightSarcastic)); 
    shortTextScoringComponent.scoreComponent("RNS",SelectDataBase.getBlogs(rightNonSarcasm)); 
    shortTextScoringComponent.scoreComponent("FNS",SelectDataBase.getBlogs(wrongNonSarcasm)); 
    shortTextScoringComponent.scoreComponent("FS",SelectDataBase.getBlogs(wrongSarcasm)); 

ノートが彼二行目が行われた後のように、それぞれの呼び出しの間の処理に長い時間があることが価値がある:そして、私は次のようにコードを持っていますsuccessfuly私はこれを意味するライン:

SelectDataBase.getBlogs(rightNonSarcasm); 

それは私が次のエラーを取得する第三のラインに来るとき:

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. 

私は多くのことを探索したが、私は混乱し、多くの異なった答えがありますが、あなたは何を私の任意のアイデアを持っています正確な問題は?例外として、すべての

+1

これを解決しましたか?私は同じ問題を抱えている – Nom1fan

答えて

1

まず、接続積極

にチェックを保つためにも、これを追加

第二

tcpKeepAlive=true

あなたはポーリングスレッドを維持することができ、あなたたconnectionStringに

autoReconnect=true

を追加しないと言います

class PollingThread extends Thread 
{ 
    private java.sql.Connection connection; 

    PollingThread(int index, java.sql.Connection connection) 
    { 
     super(); 
     this.connection = connection; 
    } 

    public void run() 
    { 
     Statement stmt = null; 
     while (!interrupted()) 
     { 
      try 
      { 
       sleep(15 * 60 * 1000L); 
       stmt = connection.createStatement(); 
       stmt.execute("do 1"); 
      } 
      catch (InterruptedException e) 
      { 
       break; 
      } 
      catch (Exception sqle) 
      { 
       /* This thread should run even on DB error. If autoReconnect is true, 
       * the connection will reconnect when the DB comes back up. */ 
      } 
      finally 
      { 
       if (stmt != null) 
       { 
        try 
        { 
         stmt.close(); 
        } catch (Exception e) 
        {} 
       } 
       stmt = null; 
      } 
     } 
関連する問題

 関連する問題