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().queryFor List(mMani festISerie sQueries.g etTerminal PrinterLis t(), PARAMS, Get_Term_Printer_List);
Map map = (Map) list.iterator();
while(((Iterator) map).hasNext())
{
((ResultSet) map).next();
_printerDefaultsVO = new manifestTerminalPrinterDef aultsVO();
_printerDefaultsVO.setTerm Num(Intege r.parseInt (dto.getpT erminal()) );
_printerDefaultsVO.setPrin terId((Str ing) al2.get(1));
_printerDefaultsVO.setPrin terDesc((S tring) al2.get(2));
_printerDefaultsVO.setTerm inalDefaul t(((String ) al2.get(3)).charAt(0));
_printerList.add(_printerD efaultsVO) ;
}
Any help would be appreciated.
List list= getJdbcTemplate().queryFor
Map map = (Map) list.iterator();
while(((Iterator) map).hasNext())
{
((ResultSet) map).next();
_printerDefaultsVO = new manifestTerminalPrinterDef
_printerDefaultsVO.setTerm
_printerDefaultsVO.setPrin
_printerDefaultsVO.setPrin
_printerDefaultsVO.setTerm
_printerList.add(_printerD
}
Any help would be appreciated.
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
actually....that worked Mccarl...thanks
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