Occasionally, a connectino to known DB does not go through for some
unknwn reason. What is the best way to "retry" this connection attempt.
Currently, I have the following
$success = 0;
$self->{DSN} =
"DBI:$self->{DRIVER}:database=$self->{DATABASE};host=$self->{SQLHOST};port=$self->{BIND_PORT}";
while ((!($success)) && ($try <= 3))
{
$self->{DBH} = DBI->connect($self->{DSN}, $self->{USER},
$self->{PASSWORD}, { RaiseError => 0, PrintError => 1});
### If I cannot connect, take a time out
if ($DBI::err != 0) {sleep(20);}
else
{$success = 1;}
$try++;
}
Will this work. Or should I put the connection attempt in an EVAL
statement and check for $@ after the statement executes.
--
Brad Phinney
Senior Technical Consultant, Sendmail Inc.
E-Mail : [EMAIL PROTECTED]
Phone : 718-275-4782
Cell : 917-531-7577