Hi Everyone!
the log shows the correct values to my query in SQL Script and store it to my array list.
But when I tried to retrieve the data in the controller, only the last value repeatedly displayed.
My SQL Query script:
select distinct (descr) from los_mca where status='A'
Send back to my DAO:
public List<RepPlanSummaryVO> getListAreas(RepPlanSummaryVO vo) {
....
List<RepPlanSummaryVO> lst = new ArrayList<RepPlanSummaryVO>();
.....
rs = stmt.executeQuery();
RepPlanSummaryVO areavo = new RepPlanSummaryVO();
while (rs.next()) {
logger.info("result: "+ rs.getString("DESCR"));
areavo.setArea_abbv(rs.getString("DESCR"));
lst.add(areavo);
}
....
Console logs:
result: Antelope Valley
result: Baldwin Park
result: Downey
result: Kern County
result: Los Angeles
result: Orange County
result: Panorama City
result: Riverside
result: San Bernardino County
result: San Diego
result: South Bay
result: West LA
result: Woodland Hills
Retrieve the "lst" in the controller:
List<RepPlanSummaryVO> list = repByPlanSER.getListAreas(planVo);
for(int i=0;i<list.size();i++) {
logger.info("lstHeaderAreas " +i);
RepPlanSummaryVO lblStr = list.get(i);
logger.info("Areas --- " + lblStr);
}
Console logs:
lstHeaderAreas 0
Areas --- Woodland Hills
lstHeaderAreas 1
Areas --- Woodland Hills
lstHeaderAreas 2
Areas --- Woodland Hills
lstHeaderAreas 3
Areas --- Woodland Hills
lstHeaderAreas 4
Areas --- Woodland Hills
lstHeaderAreas 5
Areas --- Woodland Hills
lstHeaderAreas 6
Areas --- Woodland Hills
lstHeaderAreas 7
Areas --- Woodland Hills
lstHeaderAreas 8
Areas --- Woodland Hills
lstHeaderAreas 9
Areas --- Woodland Hills
lstHeaderAreas 10
Areas --- Woodland Hills
lstHeaderAreas 11
Areas --- Woodland Hills
lstHeaderAreas 12
Areas --- Woodland Hills
I really can not pin point my mistake so, if someone every encounter this problem of mine, please help me. :'(