重複キーを避けるために HashMap を使用できます。
ResultSet rs1 = ... // here goes your first result set
ResultSet rs2 = ... // here goes your second result set
// TableRow is a class you can create which contains the fields of your result set
// including the primary key
HashMap<String, TableRow> hm = new HashMap<String, TableRow>();
// First you insert the rows from Result Set 1
while (rs1.next()) {
// Obtain primary key
String pk = rs1.getString("pkey");
// Obtain fields
String field1 = rs1.getString("field1");
String field2 = rs1.getString("field2");
// ...up to fieldN
TableRow tr = new TableRow(pk, field1, field2, ...);
hm.put(pk, TableRow);
}
// Then you insert the rows from Result Set 2
while (rs2.next()) {
// Obtain primary key
String pk = rs2.getString("pkey");
// Obtain fields
String field1 = rs2.getString("field1");
String field2 = rs2.getString("field2");
// ...up to fieldN
TableRow tr = new TableRow(pk, field1, field2, ...);
hm.put(pk, TableRow);
}
HashMap は重複キーを回避します。日付が行ごとに一意である場合は、日付を HashMap のキーとして使用することもできます。