how to get data from more than two tables based on other
Hi All,
I am new to java.
I want to get the data from 3 table.
first i will use a query on both table . after getting the result set. i want to write on more query inside the result set with where clause .
so that i will get only corresponding match records from third table in the result set.
please let me know how to write the code.
my code is as below:
try{
String sql = "select DISTINCT REQUISITIONS.FOLDERID, REQUISITIONS.AUTOREQ, REQUISITIONS.MANAGERID, REQUISITIONS.RECRUITERID, " +
" REQUISITIONRESPONSE.FOLDERID, REQUISITIONRESPONSE.QUESTION_TYPE_ID, REQUISITIONRESPONSE.RESPONSE " +
" from REQUISITIONS,REQUISITIONRESPONSE" +
" where REQUISITIONS.FOLDERID=REQUISITIONRESPONSE.FOLDERID ";
System.out.println(":kishan test data1 " );
ResultSet rs1 = st.executeQuery(sql);
while(rs1.next())
{
System.out.println(":kishan test data2 " );
int aInt = Integer.parseInt(rs1.getString(1));
Candidate candidate=new Candidate();
candidate.setRsKey(+aInt);
candidate.setEmail(rs1.getString(2));
candidate.setName(rs1.getString(3));
candidate.setPhone(rs1.getString(4));
candidate.setDegree(rs1.getString(5));
candidate.setGradyear(rs1.getString(6));
candidate.setSchoolname(rs1.getString(7));
String sql1 = "select QUESTION_TYPE_ID, QUESTION_DESC from QUESTION_TYPE where QUESTION_TYPE_ID='"+rs1.getString(6)+"'";
ResultSet rs2 = st.executeQuery(sql1);
while(rs2.next())
{
System.out.println(":kishan test data in second query " +rs2.getString(1));
if (rs2.getString(2).equals("Cost Center")){
candidate.setJobtitle(rs1.getString(7));
}else if (rs2.getString(2).equals("Business Unit")){
candidate.setOrgname(rs1.getString(7));
}
}
list.add(candidate);
}
}
Here i am getting Exhuasted Result set exception.