001package edu.pdx.cs.joy.family;
002
003import java.sql.Connection;
004import java.sql.SQLException;
005import java.util.List;
006
007/**
008 * Data Access Object interface for managing Person entities in the database.
009 */
010public interface PersonDAO {
011
012  /**
013   * Drops the persons table from the database if it exists.
014   *
015   * @param connection the database connection to use
016   * @throws SQLException if a database error occurs
017   */
018  static void dropTable(Connection connection) throws SQLException {
019    PersonDAOImpl.dropTable(connection);
020  }
021
022  /**
023   * Creates the persons table in the database.
024   *
025   * @param connection the database connection to use
026   * @throws SQLException if a database error occurs
027   */
028  static void createTable(Connection connection) throws SQLException {
029    PersonDAOImpl.createTable(connection);
030  }
031
032  /**
033   * Saves a person to the database.
034   *
035   * @param person the person to save
036   * @throws SQLException if a database error occurs
037   */
038  void save(Person person) throws SQLException;
039
040  /**
041   * Finds a person by their ID.
042   *
043   * @param id the ID to search for
044   * @return the person with the given ID, or null if not found
045   * @throws SQLException if a database error occurs
046   */
047  Person findById(int id) throws SQLException;
048
049  /**
050   * Finds all persons in the database.
051   *
052   * @return a list of all persons
053   * @throws SQLException if a database error occurs
054   */
055  List<Person> findAll() throws SQLException;
056
057  /**
058   * Updates an existing person in the database.
059   *
060   * @param person the person to update
061   * @throws SQLException if a database error occurs
062   */
063  void update(Person person) throws SQLException;
064
065  /**
066   * Deletes a person from the database by ID.
067   *
068   * @param id the ID of the person to delete
069   * @throws SQLException if a database error occurs
070   */
071  void delete(int id) throws SQLException;
072}
073