in reply to how to test a connection with mysql db

Why can't you use the inability to connect to the first database as the check itself? Seems to me if you can't connect to server A (and you will know this through DBI's error handling), you would just try to connect to server B.
  • Comment on Re: how to test a connection with mysql db

Replies are listed 'Best First'.
Re^2: how to test a connection with mysql db
by jeanluca (Deacon) on Apr 15, 2005 at 21:41 UTC
    If I try to connect, and it fails, because this server is off line, my perl-script generates a message (to screen!!) that it failed. I don't want this message to screen.
      Pass PrintError => 0 as an option in your connect string. From perldoc DBI:
      The "\%attr" parameter can be used to alter the default settings of "PrintError", "RaiseError", "Auto­ Commit", and other attributes. For example: $dbh = DBI->connect($data_source, $user, $pass, { PrintError => 0, AutoCommit => 0 });

      Update: Fixed bogus entity; added 'perldoc'.