in reply to persistent DB connection
Typically, a DB(I) connection will remain open until you close (disconnect) it. In other words, not closing it before exiting the application should be sufficient to achieve persistence... (In case you're using a lexical variable to hold the db handle, make sure it doesn't unintentionally go out of scope, or else the object's DESTROY method will automatically disconnect.)
Update: In this particular case, where there will likely be only one set of connect() parameters, I don't really see any significant advantage of using connect_cached() over using a plain connect() plus simply keeping around and 'reusing' the obtained $dbh yourself... — Except maybe for the implicit ping being done behind the scenes, which might guard you (to some degree) against the rare case that the connection has disappeared in the meantime (due to network problems, DB restart or whatever). This might make more sense for a web app where the server part keeps running for months, but for the typical usage scenario of a standalone wxPerl GUI it seems less vital...
In other words, if anyone feels like pointing out the specific advantages of using connect_cached(), please go ahead!
|
|---|