Java如何创建resultset对象,如何在Java中加入ResultSet对象?

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值