Trying to combine two ArrayList into one, below are the values of two List. W_VISIT describes how many time particular HOST_ADDR address visited the web page.
HOST_ADDR -- W_VISIT
10.202.64.52 -- 11
10.202.64.78 -- 5
10.202.64.34 -- 1
HOST_ADDR -- W_VISIT
10.146.84.179 -- 1
10.202.64.52 -- 16
10.202.64.78 -- 18
All I am trying do here is combine both array list(kind of full outer join in SQL)
Output:
10.202.64.52 -- 11 -- 16
10.202.64.78 -- 5 -- 18
10.202.64.34 -- 1 -- 0
10.146.84.179 -- 0 -- 1
and so on..
public List getData()
{
data=new ArrayList();
ResultSet rs=ps.executeQuery();
while(rs.next()){
fetchValue=new NewClass();
fetchValue.setCount(rs.getInt(1));
fetchValue.setIp(rs.getString(2));
data.add(fetchValue);
}
return data;
}
public List get2Data()
{
data1=new ArrayList();
ResultSet rs=ps.executeQuery();
while(rs.next()){
fetchValue1=new NewClass();
fetchValue1.setCount(rs.getInt(1));
fetchValue1.setIp(rs.getString(2));
data1.add(fetchValue1);
}
return data1;
}
public List get3Data(){
//what to do here... not looking for code, just seeking a way to do
}
Create a new class called IpDetails say with three fields
Define a map at Object level with ip as key and IpDetails as value.
When you fire your first query, populate the map by creating IpDetails object and populating things you get from Query and leave count 2 as uninitialized.
When you fire second query do the following:
And now you have all three details in place, so you can pass on values to the GUI as collections of IpDetails.