gskoli has asked for the wisdom of the Perl Monks concerning the following question:
In a loop i am creating DNS and connection to database . But if any host is not responding or down , then that loop is getting break and remaining host not able to connect .
My question is how can i skip that means if any host is not able to connect then i want to skip that host and want to connect with other one...Or try to reconnect that host again ...
snippet of code is given bellow
Please help me out ! Thanks in advance@arr_ =('host1','host2'); foreach $host (@arr_){ @Mydsn =("dbi:mysql:$MYSQL_DATABASE:$host:$MYSQL_PORT","$MYSQL_USER +","$MYSQL_PWD"); my $my_connection = DBI->connect(@Mydsn, { RaiseError => 0, PrintErro +r => 1 } ) or die("Fail to connect Database connection"); ### Here how can i skip if mysql is not able to connect with breaking + execution of script }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: if database connection failed try to reconnect
by andal (Hermit) on Mar 14, 2011 at 12:26 UTC | |
by gskoli (Novice) on Mar 14, 2011 at 14:16 UTC | |
|
Re: if database connection failed try to reconnect
by Anonymous Monk on Mar 14, 2011 at 12:29 UTC | |
by gskoli (Novice) on Mar 14, 2011 at 14:16 UTC |