Issue
I know this might be a basic question and I couldn't find the answer most likely because I didn't how to make one. Anyway, let's say you have this method
public static ***Student,Teacher?*** getStudent(int idStudent) {
Student student = new Student() ;
Teacher teacher = new Teacher() ;
try {
Connection con=DB.getCon() ;
java.sql.PreparedStatement ps=con.prepareStatement("select s.StudentName, s.StudentNumber,t.teacherName,t.teacherMail from student s INNER JOIN teacher t ON s.idClass = t.idClass ") ;
ps.setInt(1,idStudent) ;
ResultSet rs=ps.executeQuery() ;
while(rs.next()) {
student.setStudentName(rs.getString(1)) ;
student.setStudentNumber(rs.setInt(2)) ;
teacher.setTeacherName(rs.setString(3)) ;
teacher.setTeacherMail(rs.setString(4)) ;
}
} catch (Exception e) { System.out.println(e) ; }
***// return studdent ?;***
}
The same thing if I'm going to return a List<Student+Teacher> what is the type that should be returned. Thank you
Solution
The best approach seeing your code above would be to create a custom object with all ur required param . Then set those param and return the list of the custom object
Answered By - Praveen Gowthaman