finish the database operation