Originally posted by r035198x
The program is Complie and run Successfully but it does not return any output
please help to do this
Code:
public class KeywordCount {
public void countKeyword() {
try{
String sql1 = "select JobRefNo,ifnull(Keywords,' ') from JOB_ORDER where Status<>'Expired' and ValidUpto >= sysdate()";
Statement stm1 = dbConnection.createStatement();
ResultSet rs1 = null;
rs1 = stm1.executeQuery(sql1);
while(rs1.next()) {
String sql2 = "select UserId from JOB_APPLICATION where NoOfMatch=-1 and JobRefNo=" +rs1.getInt(1);
Statement stm2 = dbConnection.createStatement();
ResultSet rs2 = null;
rs2 = stm2.executeQuery(sql2);
while(rs2.next()) {
try {
String sql3 = "select TxtResume from CAN_RESUME where UserId="+rs2.getInt(1);
Statement stm3 = dbConnection.createStatement();
ResultSet rs3 = null;
rs3 = stm3.executeQuery(sql3);
rs3.next();
String TxtResume=rs3.getString(1);
String Keywords=rs1.getString(2);
String temp[] = Keywords.split(",");
for(int i = 0; i < temp.length;i++) {
System.out.print(temp[i]+" appears : ");
//System.out.print(countTimes(TxtResume, temp[i]) + " times");
}
} catch (Exception e) {
System.out.println("DB error while execute the SQL " + e);
}
}
rs2.close();
stm2.close();
}
}catch (Exception e) {
System.out.println("DB error while execute the SQL " + e);
}
}
public int countTimes(InputStream in ,String Keywords1){
DataInputStream din = new DataInputStream(in);
String line = null;
int count=0;
try {
while((line=din.readLine()) != null){
String line2 = line.toLowerCase();
int KeywordsLength = Keywords1.length();
for(int i = 0; i < line2.length() - KeywordsLength; i++) {
if(Keywords1.equals(line2.substring(i, i + KeywordsLength))) {
count++;
System.out.println("the count is "+count);
}
}
}
return count;
//
//rs1.close();
//stm1.close();
} catch (Exception e1) {
System.out.println("DB error while execute the SQL " + e1);
return -1;
}
}
public static void main(String arg[]) {
try
{
KeywordCount key = new KeywordCount();
key.countKeyword();
//key.countTimes();
} catch(Exception e) {
System.out.println("Exception is"+e);
}
}
}
Thankyou
Sang
Comment