MySQL Forums
Forum List  »  Perl

Validating a Successful DB connection
Posted by: Gary Sperano
Date: August 31, 2006 03:25PM

I need to understand if there is a way to sucessfully validate a DB connectio within a script. SO if the connection to the DB is successful, I want to write the data directly to the database. If the connection is not successful, as in the event the server is being rebooted, I want to write the data to a file. I do not want to use 'RaiseError' as this will cause the script to immediatly terminate. Below is the code I am using to connect

use DBI();

# Connect to the database.
my $dbh = DBI->connect("DBI:mysql:database=nb_reports;host=$MySQLserver",
"script", "Scr1pt");

Here is where I need the help

if (sucessfully connected to db) {
....
....
....
}
else {
....
....
....
}

Thanks in advance

Options: ReplyQuote


Subject
Written By
Posted
Validating a Successful DB connection
August 31, 2006 03:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.