Link to home
Start Free TrialLog in
Avatar of Jtw549
Jtw549

asked on

java iterator using list and map

Below Im trying to put the resultset of the queryForList into the functions but its not working out the way I want. I know im doing something wrong. Where ever there is a al2 in the code thats where I want to put the resultset. The way I was trying to do it was with a arraylist (al2) then getting the indexed item and putting it into the method called. I tried  Iterator<Map> iterator=list.iterator(); but it tells me to go use jre1.5...which is wierd.      

List list= getJdbcTemplate().queryForList(mManifestISeriesQueries.getTerminalPrinterList(), PARAMS, Get_Term_Printer_List);
                  
                  
                  Map map = (Map) list.iterator();
                  while(((Iterator) map).hasNext())
                  {
                        ((ResultSet) map).next();
                        _printerDefaultsVO = new manifestTerminalPrinterDefaultsVO();
                        _printerDefaultsVO.setTermNum(Integer.parseInt(dto.getpTerminal()));
                        _printerDefaultsVO.setPrinterId((String) al2.get(1));
                        _printerDefaultsVO.setPrinterDesc((String) al2.get(2));
                        _printerDefaultsVO.setTerminalDefault(((String) al2.get(3)).charAt(0));
                        _printerList.add(_printerDefaultsVO);
                        
                  }

Any help would be appreciated.
Avatar of for_yan
for_yan
Flag of United States of America image

If you want to iterate through ResultSet, it is much easier.
You just say

while(resulSet.next()){
String s1 = resultSet.getString(1);
int num = resultSet.getInt(2);


then use the values  in any functyions
ettc.

} //end of loop through ResultSet

Avatar of Jtw549
Jtw549

ASKER

Is that even possible to do with Spring, without doing a resultSet Extractor?
As far as I can understand, it should be possible to do it all directly, once
you have access to ResultSet object - these are the basic properities of resultSet which we are using.

ResultSetExtractor is supposed to simplify your interactions with database and to deal better with
error messages, etc., see, e.g.
http://www.vogella.de/articles/SpringJDBC/article.html
 but the excerpt in my posting above which relies on basic properities of ResultSet
should still work.
Well, I don't have much experience wit Spring, perhaps we'll hear from someone
who is aware of some implications for other aprts of your spring web app.
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jtw549

ASKER

actually....that worked Mccarl...thanks