Package edu.pdx.cs.joy.family
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 TypeMethodDescriptionstatic voidcreateTable(Connection connection) Creates the persons table in the database.voiddelete(int id) Deletes a person from the database by ID.static voiddropTable(Connection connection) Drops the persons table from the database if it exists.findAll()Finds all persons in the database.findById(int id) Finds a person by their ID.voidSaves a person to the database.voidUpdates an existing person in the database.
-
Method Details
-
dropTable
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
Creates the persons table in the database.- Parameters:
connection- the database connection to use- Throws:
SQLException- if a database error occurs
-
save
Saves a person to the database.- Parameters:
person- the person to save- Throws:
SQLException- if a database error occurs
-
findById
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
Updates an existing person in the database.- Parameters:
person- the person to update- Throws:
SQLException- if a database error occurs
-
delete
Deletes a person from the database by ID.- Parameters:
id- the ID of the person to delete- Throws:
SQLException- if a database error occurs
-