Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: check if DBI is still connected

by EvanCarroll (Chaplain)
on Oct 06, 2005 at 08:42 UTC ( [id://497852]=note: print w/replies, xml ) Need Help??


in reply to check if DBI is still connected

See options $dbi->{'RaiseError'} and $dbi->{'PrintError'}, querrying on a dead database will always throw an error or a warning respectively. If you set RaiseError to 1, and set PrintError to 0 (default), and capture the error message from $DBI::stderr after an eval, you can run a regex to see if it matches that of a failed connection, if it fails, reconnect and try again.

eval { $dbi = blah; $sth = blah }; if ($@ && $DBI::stderr =~ m/Bad Connection/) {reconnect and start again}


Evan Carroll
www.EvanCarroll.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://497852]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found