Changeset 113 for branches/stable
- Timestamp:
- 12/31/04 11:50:32 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/cgi-bin/CustIDCK.pm
r94 r113 32 32 33 33 # some example code for a database check 34 my $dbh = DBI->connect ("DBI:Pg:host=billing;dbname=custids", "cidcheck", "c1dch4ck"); 34 # Try to catch failures to connect. If the remote server is up but 35 # not responding (this has HAPPENED) we need to break out rather than hanging. 36 eval { 37 local $SIG{ALRM} = sub { die "failed connection to billing!!" }; 38 alarm 3; # 3-second timeout. This may be too aggressive. 39 my $dbh = DBI->connect ("DBI:Pg:host=billing;dbname=custids", "cidcheck", "c1dch4ck"); 40 alarm 0; # cancel the alarm 41 }; 42 alarm 0; # avoid race conditions. May not be needed here. (Hah!) 43 if ($@ && $@ !~ /failed connection to billing!!/) { 44 $CustIDCK::Error = 1; 45 $CustIDCK::ErrMsg = "Failed connection to billing DB host! Unable to verify CustIDs."; 46 return 0; 47 } 48 35 49 my $sth = $dbh->prepare("SELECT custid FROM custid WHERE custid = '$custid';"); 36 50 $sth->execute;
Note:
See TracChangeset
for help on using the changeset viewer.