jdbc - Comparing Resultsets In java -
i looking ways compare 2 resultset
s in java (rs1
, rs2
).
things note/requirements
the results sets 2 different databases(
oracle
&sql-server
).thus can't make sql query changes copare results fetched.any of
resultset
s can have more rows each other.any of
resultset
can have data not in otherresultset
example:
rs1 rs2 column1 column2 column1 column2 column3 1 2 item1 c 1 b 4 item2 d 2 c 2 item3 e 5 d 1 item4
expected result
==> valid , because in rs1
& rs2
, column2
in rs2 > column2
in rs1
==> b invalid, not there in rs1
==> c valid , because in rs1
& rs2
, column2
c in rs2 > column2
c in rs1
==> d invalid , because though there in rs1
, rs2
,the column2
d in rs2 < column2
d in rs1
==> e invalid because not there in rs2
looking possible options solve issue.
traverse through both resultset
s , store them in map<string, integer>
. after can traverse through either of keyset
, keep comparing values
.
this lets compare 2 resultset
s kind of db(oracle, mysql, sqlserver, etc.
).
Comments
Post a Comment