Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Perl DBI Question

by Coruscate (Sexton)
on Jan 21, 2004 at 17:34 UTC ( [id://323046]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Perl DBI Question
in thread Perl DBI Question

Close, but not what the OP was asking for. That will automatically die if the connection fails. Either what pg provided or something like the following would be more of a workable solution:

#!c:/perl/bin/perl -w $|++; use strict; use DBI; my $table = 'table_name'; my @db = ( ['localhost', 'user1', 'pass1'], ['other.server.com', 'user2', 'pass2'], ['last.attempt.com', 'user3', 'pass3'], ); my $dbh; for my $db (@db) { eval { $dbh = DBI->connect( 'dbi:mysql:database=' . $table . ';host=' . $db->[0], $db->[1], $db->[2], { AutoCommit => 1, RaiseError => 1 } ); }; next if $@; } die "Unable to connect to any database!\n" if not defined $dbh;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://323046]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.