At 02:19 PM 6/2/2001 +0800, sskau wrote:
>Dear All:
> i have a long-running WebKit servlet that constantly acess the
>MySQL database (with class and instance caching enabled). I store the
>datbabase connection obj in the servlet instance
>(like self.db = MySQLdb.connect(....)). After one day, i found the
>MySQLdb complaining OperatioalError and no databse selected.
>I guess it's because the connection has timeout. Does anyone knows
>about how to detect this error and reconnect it when necessay ?
I discovered the same problem a couple of weeks ago or so. I haven't fixed
this yet, but here are some thoughts:
You could run all your SQL through a function/method that would catch the
given exception and upon doing so, reconnect and execute the SQL again.
You could schedule a task to close the connection if it hasn't been used in
some time period (perhaps an hour). That same process could re-open the
connection immediately, or you could do that upon needing the connection.
See TaskKit for scheduling.
If you end up trying something, let us know how it goes.
-Chuck
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/webware-discuss