Re: [Sqlrelay-discussion] I need help -- Sometimes I got this : nativecode=Couldn't connect to the
Brought to you by:
mused
|
From: Dante M. <ma...@si...> - 2007-09-12 04:35:57
|
Hey!
It seems like I found a way to prevent this error by adding a stupid loop after "DB:isError".
something like:
********* getting connection *********************
$connected = 0;
if ( DB::isError($dbh) ){
for( $i=0; $i<10; $i++ ){
/* try 10 times */
$dbh = DB::connect("$type://$user:$pass@$host:$poolport/$dbname");
if ( !DB::isError( $dbh) ) {
$connected = 1;
break;
} else {
sleep(1);
}
}
}
if($connected!=1) die("connect error:".$this->dbh->getDebugInfo()."\n");
********* doing query *********************
if (DB::isError($result)){
$got_res=0;
if(strpos($result->getDebugInfo(),"Couldn't connect to the listener") ){
/* try to do the query 5 times */
for($i=0;$i<5;$i++){
$result = $this->dbh->getAll($sql, DB_FETCHMODE_ASSOC) ;
if(DB::isError($result)){
sleep(1);
} else {
$got_res=1;
break;
}
}
}
if($got_res!=1) die("query error:".$result->getDebugInfo()."\n") ;
}
I don't know if this is a good way to prevent that error, but it works.
Regards,
Dante Mason
|