I have two connections .
Connection cone = ... // to DB2
Statement statement = cone.createStatement();
ResultSet resultSet1 = statement.executeQuery("select * from tableone");
Connection ctwo = ... // to Teradata
Statement statement = ctwo .createStatement();
ResultSet resultSet2 = statement.executeQuery("select * from tabletwo");
How can I join these two tables ?
so far i am writing the above result sets to csv using opencsv API . And then manipulate the two csv files . I am sure my approach is far from ideal , it takes time and not efficient
There must be an efficient solution . After all , the two result sets are java objects . There must be a way of joining them without third party API
解决方案
Creating a temporary table in DB2 as it was mentioned , might not be the best way . Simply due to permission restrictions . The question asks clearly , how to join two result set objects.
I believe there was an answer on Stackoveflow
while (rs1.next) {
YourClass obj = new YourClass();
obj.setSomeProperty(rs.getString(1));
obj.setAnotherProperty(rs.getString(2));
// etc..
cominbedDataSet.add(obj);
}
good luck