I am trying to validate fixed length file count with the database count where when it match the counts then pass statement is not executing in the if statement however, it is going to else statement. Any direction will be apprpriciated.
Following is my code:
static String ubservicesCount = "";
String connectionUrl = "jdbc:sqlserver://"+strpServer+":"+strpPort+";databaseName="+strpDatabase+";IntegratedSecurity=true";
// Declare the JDBC objects.
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);
String SQL = strpQuery5+Qt+ProcessID+Qt;
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next()) {
ubservicesCount = rs.getString(1);
System.out.println("UB servicesCount is " +ubservicesCount);
}
String st;
BufferedReader Br = null;
File objFile = new File(strPlanFile+NewFileNmae);
Br = new BufferedReader(new FileReader(objFile));
List<String> list = new ArrayList<String>();
while ((st = Br.readLine()) != null) {
String arraylist = st;
String RcdType = arraylist.substring(0, arraylist.length()-392);
list.add(RcdType);
}
Set<String> unique = new HashSet<String>(list);
for (String key : unique) {
if(key.trim().toString().equals("SALINE")){
System.out.println(key + ": " + Collections.frequency(list, key));
int fileCount = Collections.frequency(list, key);
if(ubservicesCount.trim().toString().equals(fileCount))
objReport.setValidationMessageInReport("PASS", "Flat File "+key+" count "+fileCount+" is Matched with Database ubdiagcodes Count "+ubservicesCount);
else
{
objReport.setValidationMessageInReport("FAIL", "Flat File "+key+" count "+fileCount+" is not Matched with Database ubdiagcodes Count "+ubservicesCount);
}
}
}
Br.close();
After the execution it print failed in the else statement in my report. I debugged where I can see that in the compare statement it is matching the counts. I am not sure what I am missing here.
Aucun commentaire:
Enregistrer un commentaire