Added proper error handling for DB connection errors