Hello guys, I am very new to Java. I've been trying to select two different tables but fails. The error is "Invalid operation at current cursor position.". Here is my code.
private void display() throws SQLException{
TableModel model = schedTable.getModel();
PreparedStatement stmt = con.prepareStatement("select * from APP.SCHEDULE");
ResultSet sched = stmt.executeQuery();
while(sched.next()){
stmt = con.prepareStatement("select * from APP.SUBJECT where subjectNum='OOP2'");
ResultSet subj = stmt.executeQuery();
model.setValueAt(sched.getInt("numOfStud"), 0, 0);
model.setValueAt(subj.getString("name"), 0, 1);
break;
}
}
As you can see, I am still learning this stuff. I haven't fully understood how statement and resultset works yet. I would very much appreciate it if you would explain it to me.