The update code block, as it is, runs without errors and updates as intended. The finally block - I see your point on that one, edited those in.
Our coursework didn't cover prepared statements, and I'm... frankly, a little too overwhelmed right now. Resultset - got that, editing that in, too.
On looking at it, I'm wondering if I need to do too much more to it. The problem with the updating is that the three types (graduate, undergrad, parttime) all have different sets of information that need to be updated. All of them have the basic set (firstname, lastname, gpa, mentor, studentid) but graduate adds in (thesistitle, thesisadvisor) and parttime adds (company). I can't think of a way to properly update without using the current system. The other student I spoke to used a similar setup and his project passed, so I think I might throw it to the reviewers and see if they will take it.
And of course I run into more issues.
private void deleteStudent(){
Connect gc = new Connect();
Statement stmt = null;
Connection conn = gc.getSimpleConnection();
try
{
stmt = conn.createStatement();
System.out.println("Enter Student ID:");
while (!scan.hasNextInt()) {
scan.next();
}
int id = scan.nextInt();
scan.nextLine();
stmt.execute("Delete FROM student WHERE studentID=" + "'" + id + "'");
stmt.close();
conn.close();
}
catch (SQLException e)
{
e.printStackTrace();
System.err.println("Could not delete student");
}
System.out.println("Successfully deleted student from the database");
}
This is my current delete student code block. When I try to move the conn.close(); etc outside into a finally block, it red-lines it and wants to surround it by a try/catch block or add a "throws SQL" to the constructor. But when I do THAT, the case set up top doesn't like it because deleteStudent(); no longer matches. God, what a headache.