I have the following structure:
List -->List_Participant -->Participant
so a list may contain several participants.I try to read this in java:
stat = con.createStatement();
ResultSet rs = stat.executeQuery("select * from list;");
// get the informations about the bracket sheet
while (rs.next()) {
string name = rs.getString("Name");
ResultSet rs2 = stat.executeQuery("select * from List_Participant where name= '"+name+"';");
while (rs2.next()) {
// get the participants
}
rs2.close();
}
rs.close();
But this does not work. I don't receive an exception nor any other output. I suggest opening a second resultset will close the first one because since I do the first resultset, store the data in an arraylist and close it and afterwards the second it would work, but that leads to a poor performance because I have to search always in the arraylist.
What might be a better solution?
Edit: Solution is to make a Join, my current try:
select * from List_participant
INNER JOIN List ON List.name = List_participant.List
INNER JOIN participant ON List_participant.participant =participant.ROWID;
How do I adress the columns now, since they might have the same name?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…