I'm making a StudentAdministration project with a Usercontroller, studentrepository, some html templates, a css stylesheet and a mySql database. Everything is working out great, and i see my index site, but im having problem creating students because of the Date attribute at my Student class.
In my controller, this is how i create:
@Override
public void create(Student st) {
jdbc.update("INSERT INTO studentdb.student(firstName, lastName,
enrollmentDate, password, cpr)
" + "VALUES('" + st.getFirstName() + "',
'" +
st.getLastName() + "', '" + st.getEnrollmentDate() + "', '" +
st.getPassword() + "', '" + st.getCpr() + "') ");
}
the problem is the st.getEnrollmentDate because it gives me another date format than the 1 MySql accepts. What should i do here? I'd rather not start changing the Date attribute to a String even though that would fix the problem.