ping()
$dbh->ping()Use this function to determine whether a MySQL server is still running and the database connection is still available. There are no arguments for this method. Here is an example:
...
$sth->finish();
my $alive = $dbh->ping();
if($alive) { print "MySQL connection is still alive.\n"}
else{ print "MySQL connection is not alive.\n"}
$dbh->disconnect();
if($dbh->ping()) { print "MySQL connection is still alive.\n"}
else{ print "MySQL connection is not alive.\n"}
...The results will show that the connection is alive after the
finish() is called, but not after
disconnect().