But this is just a hack...
What if database server goes down, destroying all connections, and comes back up?
Play will throw error on first database access.
How can I have database connection pool to reconnect (maximum of N times or seconds before giving up) instead of erroring out?
On Fri, Feb 1, 2013 at 12:13 PM, Sam Lee
<sky...@gmail.com> wrote:
db.default.maxConnectionAge=7 hour
does the trick.
This forces play to close connection after 7 hours (idle or not).
On the next request that uses anorm, new connection will be made.
It's silly that it errors out when mysql closes connection.
Or, it kinda makes sense because when you are dumped, you feel sad.. But when you dump someone, you feel superior.
On Fri, Feb 1, 2013 at 11:55 AM, Sam Lee
<sky...@gmail.com> wrote:
Hey,
I'm using 2.0.4 scala anorm and MySQL.
MySQL closes idle connections (after 8 hours by default. you can set it with wait_timeout).
Once connection is closed by MySQL, the next request errors out with:
[error] Database access problem. Killing off all remaining connections in the connection pool. SQL State = 08S01
....
(I'm not sure why it is killing off all remaining connections...)
And subsequent request that uses anorm will be okay.
Then after sometime, no request comes and MySQL closes idle connections. Then, the play app is waiting to error out on next request.
I tried various combinations of bonecp configurations on :
http://www.playframework.org/documentation/2.0.4/SettingsJDBC
But, nothing really reconnects when connection is dead.
I also tried to pass ?autoReconnect=true on db.default.url... but config parser appends ?useUnicode=yes making jdbc choke.
Is there a workaround other than increasing MySQL wait_time longer and longer?
Ideally, I would like bonecp to reconnect automatically instead of killing all connections and start over.