I have these table in my notepad and accessing the notepad from my Java (GWT)
I want the fields parent code and teacher name from table Interviews: I am getting the parentcode Correctly but the problem is that TeacherName is not present in Interviews Table, I have to get teacher name from Teacher’s Table , How can i do JOIN ?
Thanks
##Teachers
#teacherId teacherCode teacherName roomCode
56750 AC Langton, Wylie 4CJKH
56751 AF Nestler, Shannae FTEJH
56752 AH O'connell, Shannae Q7STH
##Interviews
#parentCode studentKey yearLevel teacherCode
parentof.400052328 400052328 8 AH
parentof.400052328 400052328 8 KR
parentof.400052328 400052328 8 NAt
Code to get values from the above table
public ArrayList<Interviews> getParent() throws Exception{
ArrayList<Interviews> interviewList = new ArrayList<Interviews>();
int interviewStartLine = 9753 ;
int interviewEndLine = 9794 ;
try {
FileInputStream fstream = new FileInputStream("c:/work/data1.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine ="";
int j =0;
for(int i = 0 ; i<interviewStartLine ; i++){
j++;
br.readLine();
if(j==9753){
for(int line = j ; line<interviewEndLine ; line++){
strLine = br.readLine().trim();
if ((strLine.length()!=0) && (strLine.charAt(0)!='#')) {
String[] teachers = strLine.split("\\s+");
System.out.println(strLine);
Interviews interview = new Interviews();
interview.setParentCode(teachers[3]);
interview.setTime(teachers[5]);
interviewList.add(interview);
}}}
}
in.close();
} catch (Exception e) {// Catch exception if any
System.err.println("Error: " + e.getMessage());
}
return interviewList;
}
Interview Class:
private String parentCode;
private String time;
private Students studentName;
private Teachers teacherName;
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
I think the proper way is to read the file, extract the structures and then manipulate them. For example, design a Teacher Class containing the teacher parameters:
The same goes for Interview which is a class containing a reference to a Teacher