Added db.close() to the getAllPairs methods