On Mon, Jul 19, 2010 at 8:29 AM, Dietrich Streifert <dietrich.streif...@visionet.de> wrote: > > That is what I'm actually doing. I use dbh->ping() to test if the > connection is still active and reconnect to the db if needed.
If you're using the class variable to store your DB handle, what was your concern with performance? (I.e., it sounds like you're doing it right.). BTW: The ping method is slightly different than what I described. The difference could be important if you're obsessed with performance. If you ping, you're doing that before the DB operation. In most cases, the connection is fine, so there's no reason to ping. It's a wasted operation. You should really concerned with exception handling. Since all DB operations should be wrapped in an eval to catch unexpected DB errors, you can just use that to trap the non-connected state on the first operation. Then you're not pinging all the time. And, you'll catch (and retry) problems which ping won't catch. I've had zombie connections that appeared to be alive with ping, but failed. In some cases they hung indefinitely even though ping returned immediately. That's probably overkill for most people. But, if you get into DB lazy-connecting and error-handling, I think it naturally leads to what I described. It doesn't require any extra processing because you should use eval anyway. It's just using to catch everything -- even when a reconnect is needed. (I.e., when even the first connection is needed.). Mark ##### CGI::Application community mailing list ################ ## ## ## To unsubscribe, or change your message delivery options, ## ## visit: http://www.erlbaum.net/mailman/listinfo/cgiapp ## ## ## ## Web archive: http://www.erlbaum.net/pipermail/cgiapp/ ## ## Wiki: http://cgiapp.erlbaum.net/ ## ## ## ################################################################