Added check to determine if the DB connection has been closed. If yes, then get a new connection.