Learn JDBC basics using:
- exceptions
- file / database persistence concepts
- embedded H2
- repository pattern
- Maven project structure
- a one-to-many relationship
All classes must use packages under:
edu.sdccd.cisc191
This project uses a structure that can later be replaced with JPA:
model→ plain Java objectsrepository→ persistence contracts + JDBC implementationsservice→ business logicutil→ database configuration / initializationapp→ application entry point
A Student has many Course objects.
Database tables:
studentscourseswithstudent_idforeign key →students.id
Implement:
StudentCourseStudentRepositoryCourseRepositoryJdbcStudentRepositoryJdbcCourseRepositoryStudentServiceDatabaseConfigDatabaseInitializerMain
Your application must:
- create both tables if they do not exist
- insert at least 3 students
- insert at least 3 courses linked to students
- list all students
- find one student by ID
- list courses for a student
- update one student GPA
- delete one student
- print results before and after changes
Student:
id > 0nameis not null/blankgpais between0.0and4.0
Course:
id > 0titleis not null/blankstudentId > 0
mvn test- Use
PreparedStatementinstead of building SQL by string concatenation - Use
try-with-resources - Throw
IllegalArgumentExceptionfor invalid model data - Runtime wrapping of
SQLExceptionis acceptable for this lab