Package edu.pdx.cs.joy.jdbc
Class AcademicTermDAOImpl
java.lang.Object
edu.pdx.cs.joy.jdbc.AcademicTermDAOImpl
- All Implemented Interfaces:
AcademicTermDAO
Data Access Object implementation for managing AcademicTerm entities in the database.
Demonstrates JDBC operations with date fields: CREATE, READ, UPDATE, DELETE.
-
Constructor Summary
ConstructorsConstructorDescriptionAcademicTermDAOImpl(Connection connection) Creates a new AcademicTermDAOImpl with the specified database connection. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateTable(Connection connection) Creates the academic_terms table in the database if it does not already exist.voiddelete(int id) Deletes an academic term from the database by ID.static voiddropTable(Connection connection) Drops the academic_terms table from the database if it exists.findAll()Finds all academic terms in the database.findById(int id) Finds an academic term by its ID.findByName(String name) Finds an academic term by its name.voidsave(AcademicTerm term) Saves an academic term to the database.voidupdate(AcademicTerm term) Updates an existing academic term in the database.
-
Constructor Details
-
AcademicTermDAOImpl
Creates a new AcademicTermDAOImpl with the specified database connection.- Parameters:
connection- the database connection to use
-
-
Method Details
-
dropTable
Drops the academic_terms table from the database if it exists.- Parameters:
connection- the database connection to use- Throws:
SQLException- if a database error occurs
-
createTable
Creates the academic_terms table in the database if it does not already exist.- Parameters:
connection- the database connection to use- Throws:
SQLException- if a database error occurs
-
save
Saves an academic term to the database. The term's ID will be automatically generated by the database and set on the object.- Specified by:
savein interfaceAcademicTermDAO- Parameters:
term- the academic term to save- Throws:
SQLException- if a database error occurs
-
findById
Finds an academic term by its ID.- Specified by:
findByIdin interfaceAcademicTermDAO- Parameters:
id- the ID to search for- Returns:
- the academic term with the given ID, or null if not found
- Throws:
SQLException- if a database error occurs
-
findByName
Finds an academic term by its name.- Specified by:
findByNamein interfaceAcademicTermDAO- Parameters:
name- the name to search for- Returns:
- the academic term with the given name, or null if not found
- Throws:
SQLException- if a database error occurs
-
findAll
Finds all academic terms in the database.- Specified by:
findAllin interfaceAcademicTermDAO- Returns:
- a list of all academic terms
- Throws:
SQLException- if a database error occurs
-
update
Updates an existing academic term in the database. Uses the term's ID to identify which record to update.- Specified by:
updatein interfaceAcademicTermDAO- Parameters:
term- the academic term to update- Throws:
SQLException- if a database error occurs
-
delete
Deletes an academic term from the database by ID.- Specified by:
deletein interfaceAcademicTermDAO- Parameters:
id- the ID of the academic term to delete- Throws:
SQLException- if a database error occurs
-