Interface PersonDAO

All Known Implementing Classes:
PersonDAOImpl

public interface PersonDAO
Data Access Object interface for managing Person entities in the database.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    createTable(Connection connection)
    Creates the persons table in the database.
    void
    delete(int id)
    Deletes a person from the database by ID.
    static void
    dropTable(Connection connection)
    Drops the persons table from the database if it exists.
    Finds all persons in the database.
    findById(int id)
    Finds a person by their ID.
    void
    save(Person person)
    Saves a person to the database.
    void
    update(Person person)
    Updates an existing person in the database.
  • Method Details

    • dropTable

      static void dropTable(Connection connection) throws SQLException
      Drops the persons table from the database if it exists.
      Parameters:
      connection - the database connection to use
      Throws:
      SQLException - if a database error occurs
    • createTable

      static void createTable(Connection connection) throws SQLException
      Creates the persons table in the database.
      Parameters:
      connection - the database connection to use
      Throws:
      SQLException - if a database error occurs
    • save

      void save(Person person) throws SQLException
      Saves a person to the database.
      Parameters:
      person - the person to save
      Throws:
      SQLException - if a database error occurs
    • findById

      Person findById(int id) throws SQLException
      Finds a person by their ID.
      Parameters:
      id - the ID to search for
      Returns:
      the person with the given ID, or null if not found
      Throws:
      SQLException - if a database error occurs
    • findAll

      Finds all persons in the database.
      Returns:
      a list of all persons
      Throws:
      SQLException - if a database error occurs
    • update

      void update(Person person) throws SQLException
      Updates an existing person in the database.
      Parameters:
      person - the person to update
      Throws:
      SQLException - if a database error occurs
    • delete

      void delete(int id) throws SQLException
      Deletes a person from the database by ID.
      Parameters:
      id - the ID of the person to delete
      Throws:
      SQLException - if a database error occurs