0

Tomcat 7 に grails アプリケーションをデプロイしました。通常はデータベース接続は正常に機能しますが、夜になると接続が切断されます。翌日、Tomcatを再起動して機能させる必要があります。

構成ファイル内の接続文字列は次のとおりです。

production {
        dataSource {
            dbCreate = "update"
            pooled = true
                        logSql = true
                        driverClassName =  "com.mysql.jdbc.Driver"
                        dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
                        url =
            properties {
               maxActive = -1
               minEvictableIdleTimeMillis=1800000
               timeBetweenEvictionRunsMillis=1800000
               numTestsPerEvictionRun=3
               testOnBorrow=true
               testWhileIdle=true
               testOnReturn=true
               validationQuery="SELECT 1"
            }
        }

エラーログ:

Broken pipe. Stacktrace follows:
java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
        at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3832)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2471)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2728)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2678)
        at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1612)

また、ログ ファイルにこのメッセージが表示されます。

appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.

接続タイムアウトの問題を修正するにはどうすればよいですか。

4

1 に答える 1

2

接続 URLに追加する必要がautoReconnect=trueあります。これは、このような接続の問題に役立ちます。

お気に入り:

production {
  dataSource {
    ...
    url = 'jdbc:mysql://localhost/dbname?autoReconnect=true'
    ...
  }
}
于 2013-05-18T13:00:14.720 に答える