package com.WellsFargo.wim.Common;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class CompareTwoResultSet {
static Statement srcStatement = null;
static Statement tgtStatement = null;
static {
srcStatement = Connect_To_Oracle.connectToDB();
tgtStatement = Connect_To_Oracle.connectToDB();
}
public static boolean getDataFromDB(String odsSql, String udmStgSql) {
boolean isMatched = false;
try {
ResultSet srcResultSet = srcStatement.executeQuery(odsSql);
ResultSet tgtResultSet = tgtStatement.executeQuery(udmStgSql);
while (srcResultSet.next() & tgtResultSet.next()) {
isMatched =compareTwoTableColumn(srcResultSet, tgtResultSet);
}
System.out.println(“COMPARISION PROGRAM COMPLETED…”);
} catch (Exception e) {
System.out.println(“base code”);
e.printStackTrace();
}
return isMatched;
}
private static boolean compareTwoTableColumn(ResultSet srcResultSet, ResultSet tgtResultSet) throws SQLException {
boolean isMatched =true;
// src
String srcsystemid = srcResultSet.getString(“systemid”);
String srcorderstatus = srcResultSet.getString(“orderstatus”);
String srcside = srcResultSet.getString(“side”);
String srcordertotvalue = srcResultSet.getString(“ORDER_TOT_VALUE”);
String srcorderDTvalue = srcResultSet.getString(“ORDER_DT”);
String srcExeDt = srcResultSet.getString(“EXECUTION_DT”);
String srcTraderVal = srcResultSet.getString(“TRADER_NAME”);
String srcBusnsUnit = srcResultSet.getString(“BUSINESS_UNIT”);
// tgt
String tgtsystemid = tgtResultSet.getString(“systemid”);
String tgtorderstatus = tgtResultSet.getString(“orderstatus”);
String tgtside = tgtResultSet.getString(“side”);
String tgtordertotvalue = tgtResultSet.getString(“ORDER_TOT_VALUE”);
String tgtorderDTvalue = tgtResultSet.getString(“ORDER_DT”);
String tgtExeDt = srcResultSet.getString(“EXECUTION_DT”);
String tgtTraderVal = srcResultSet.getString(“TRADER_NAME”);
String tgtBusnsUnit = srcResultSet.getString(“BUSINESS_UNIT”);
if (!(srcsystemid.equals(tgtsystemid) & srcorderstatus.equals(tgtorderstatus) & srcside.equals(tgtside)
& srcordertotvalue.equals(tgtordertotvalue) & srcorderDTvalue.equals(tgtorderDTvalue)
& srcExeDt.equals(tgtExeDt) & srcTraderVal.equals(tgtTraderVal)
& srcBusnsUnit.equals(tgtBusnsUnit))) {
System.out.println(“One of the column value did not match”);
System.out.println(“Soucre Data – Expected”);
System.out.println(“Syetmid =” + srcsystemid + “|” + ” ” + “OrderStaus = ” + srcorderstatus + “|” + ” ”
+ “Side = ” + srcside + “|” + ” ” + “OrderTotalvalue = ” + srcordertotvalue + “|” + “ORDER_DT = ”
+ srcorderDTvalue + “|” + “Execution_Date = ” + srcExeDt + “|” + “Trader_Name = ” + srcTraderVal + “|”
+ “Business_Unit =” + srcBusnsUnit);
System.out.println(“Target Data – Actual”);
System.out.println(“Syetmid = ” + tgtsystemid + “|” + ” ” + “OrderStaus = ” + tgtorderstatus + “|” + ” ”
+ “Side = ” + tgtside + “|” + ” ” + “OrderTotalvalue = ” + tgtordertotvalue + “|” + “ORDER_DT = ”
+ tgtorderDTvalue + “|” + “Execution_Date = ” + tgtExeDt + “|” + “Trader_Name = ” + tgtTraderVal + “|”
+ “Business_Unit = ” + tgtBusnsUnit);
System.out.println();
isMatched =false;
}
return isMatched;
}
}