Check if the connection to the database is available
is there any method to check if the connection is available or not?

If you mean class method, then no, because it wouldn’t be necessary. You can simply catch the exception, which will tell you immediately that the connection was not successful:
try {
  // Code using a database connection
} catch (ConnectionNotDefinedException $e) {
  // No database for you
}