我想在我的Play Framework 2.0應用程序的application.conf文件中設置autoReconnect = true mysql連接屬性。但它給我以下錯誤:如何在Play Framework配置文件中爲mysql db url設置autoReconnect屬性?
Caused by: java.sql.SQLException: The connection property 'autoReconnect' only accepts values of the form: 'true', 'false', 'yes' or 'no'. The value 'true?useUnicode=yes' is not in this set.
這是application.conf文件我的連接字符串:
db.default.url="mysql://db_user:[email protected]/mydb?autoReconnect=true"
我想是因爲我得到這個錯誤設置此連接參數我之後應用程序空閒時間長:
[error] c.j.b.ConnectionHandle - Database access problem. Killing off all remaining connections in the connection pool. SQL State = 08S01
[error] application - Failed to login the user : guest
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully
received from the server was 153,398,761 milliseconds ago.
The last packet sent successfully to the server was 153,398,762 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.
我也嘗試設置這些戲DB參數如下(https://groups.google.com/forum/#!topic/play-framework/KzvbZ61j9Eo)中提到,以解決這方面的問題,但它沒有解決問題。
idleConnectionTestPeriod=10
testConnectionOnCheckin=true
任何指導解決這個問題將不勝感激。
謝謝。
做了這項工作?我添加了?autoReconnect = true的jdbc url,但當我等待太久stil得到相同的錯誤,它不會自動重新連接 – Gavriel