Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: check if DBI is still connected

by radiantmatrix (Parson)
on Oct 06, 2005 at 16:02 UTC ( [id://497978]=note: print w/replies, xml ) Need Help??


in reply to check if DBI is still connected

Any of the above answers will suit you, but I found this solution to be useful for a similar task of mine, as it does most of the work for you:

our @connection = ($dsn, $user, $passwd, \%options); our $dbh = DBI->connect_cached( @connection ); sub do_query { my = shift; $dbh = DBI->connect_cached( @connection ); ## do query ## }

connect_cached() connects if you aren't currently connected. Of course, you can do this yourself by using:

unless ($dbh->ping) { $dbh = DBI->connect(@connection); }

But why?

<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-19 11:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found