I have some code that runs a db call to get a list. Then loops through that list and executes a query from a different database for every record in that list. Something like the following...
public List<Cars> getCars ()
CarDAO carDAO = new CarDAO();
List<Car> cars = carDao.getCars();
for (Car car: cars){
DefectDAO defectDAO = new DefectDAO();
defectDAO.getDefects(car.getId())
}
DefectDAO
public List<HashMap<String, Object>> getDefects (String carId)
// run jdbc query over db2 database A
....
}
CarDAO
public List<Cars> getCars ()
// run jdbc query over db2 database B
....
}
I'm using java 1.5 and db2 9.7. My db2 databases are not federated.
I have read it's not good practice to perform a programmatic join in java but I think in this scenario it would help improve the performance.
Rather than manually looping though each list and doing the join programmatically can anyone suggest a library I could use? I'm thinking a library might be better because it's likely to make my code neater and hopefully work as efficiently as possible.
I'm also open to other suggestions / feedback.
thanks