Nandy
Nandy

Reputation: 11

best way to Compare 2 resultsets

Im trying to compare 2 resultsets..

There are 2 results sets rs and rs1.They are fetched from the same table running in different instance of DB

ie rs has the value of "SELECT * FROM TABLE1" from instance 1 ie rs1 has the value of "SELECT * FROM TABLE1" from instance 2

is there way to compare the 2 resultsets without iterating (while(rs.next()) through each row in resultset..

is it possible to just find the difference between rs and rs1..

i tried iterating and comparing some columns ..also tried compareto ...but the system performance is slow..the tables have min of 60K records with 20 columsn..so im looking for help to come up with best comparison

Thanks

Upvotes: 1

Views: 1250

Answers (1)

Hendra Jaya
Hendra Jaya

Reputation: 1628

Here are several approaches i can think of :

  1. Solve it through SQL statement IN and NOT IN
  2. Java's Set has several built-in method like containsAll(Collection), retainAll(Collection), removeAll(Collection). You can employ them solve your problem

Upvotes: 2

Related Questions