我正在尝试在Play Framework 2.0应用程序的application.conf文件中设置autoReconnect = true mysql连接属性。但它给了我以下错误:
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:db_user@localhost/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
对于解决这个问题的任何指导都将不胜感激。
感谢。
答案 0 :(得分:9)
显然有些东西会在你的URI中附加'?useUnicode = yes',所以你最终得到了
mysql://db_user:db_user@localhost/mydb?autoReconnect=true&useUnicode=yes
解析这个会让你知道autoReconnect的值是是吗?useUnicode = yes
稍微深入一点,也许您的连接池或数据抽象层正在这样做。
答案 1 :(得分:6)
你有2个连接参数,用&连接它们代替 ? :
mysql://db_user:db_user@localhost/mydb?autoReconnect=true&useUnicode=yes