I have two result sets (rs1 and rs2) having same fields. Now how to combine those two result sets into one so that duplicate rows are shown once.
if the two ResultSets are from the same database then why not combine them during the retrieval by using union; e.g.
select A, B
from C
union
select A, B
from D
However, if this is not an option then I suggest defining a Row class to represent a Row extracted from your ResultSet and implementing equals / hashCode to allow the Row to be compared for equality. Then simply add each Row to a Set (e.g. HashSet) in order to remove duplicates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With