Apache::DBI has the built-in ping method which was used to check if a
connection is alive.
You may referer that.

On Mon, Jul 21, 2008 at 7:14 AM, Ravi Malghan <[EMAIL PROTECTED]> wrote:
> Hi: I have a script which connects to a database when it starts up
> $dbh = 
> DBI->connect("dbi:Pg:dbname=$dbname;host=$host;port=$port;","$username", 
> "$password", {AutoCommit => 1});
> followed by a while loop which runs a query for this connection at 60 second 
> intervals. If the database goes down for some reason, I want the script to 
> try reconnecting to the database. How do I figure out within the while look 
> if the database connection is still valid. If tried using the $dbh variable 
> (if ($dbh)then connection is fin. else connection is bad). That doesn't seem 
> to work. How do I figure out if the $dbh connection has been lost within the 
> while loop?
> Any suggestions.
> TIA
> Ravi
>
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to