web-dev-qa-db-ja.com

Playフレームワーク構成ファイルでmysql db urlのautoReconnectプロパティを設定するにはどうすればよいですか?

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.

ここで説明したように、これらのplay dbパラメータを設定してこの接続の問題を修正しようとしましたが( https://groups.google.com/forum/#!topic/play-framework/KzvbZ61j9Eo )、それはしませんでしたt問題を解決します。

idleConnectionTestPeriod=10
testConnectionOnCheckin=true

この問題を解決するためのガイダンスをいただければ幸いです。

ありがとう。

10
invinc4u

明らかに何かが '?useUnicode = yes'をURIに追加しているので、

mysql://db_user:db_user@localhost/mydb?autoReconnect=true&useUnicode=yes

これを解析すると、autoReconnectの値はtrue?useUnicode = yesになります。

少し掘り下げてみてください。おそらく接続プールまたはデータ抽象化レイヤーがそれを行っています。

9
Omry Yadan

2つの接続パラメーターがあり、それらを&ではなく&で連結します。 :

mysql://db_user:db_user@localhost/mydb?autoReconnect=true&useUnicode=yes
6
AIMIN PAN