Pessoal, estou querendo iterar em um servlet um array que é carregado num DAO, o problema q estou tendo é que está percorrendo o array mas não traz os valores!!! Veja as duas classes abaixo:
Meu DAO:
public class DAOTeste{
public DAOTeste(){}
@SuppressWarnings({"deprecation","unchecked"})
public ArrayList dados(VOTeste vo) throws SQLException, Exception{
Conexao cnx = new Conexao();
ArrayList array = new ArrayList();
PreparedStatement sql = null;
ResultSet rs = null;
try {
cnx.conecta();
sql = cnx.conn.prepareStatement
("SELECT valor,data FROM tabela ");
rs = sql.executeQuery();
while(rs.next()){
vo = new VOTeste();
vo.setValor (rs.getString(1));
vo.setData (rs.getString(2));
array.add(vo);
}
rs.close();
sql.close();
}
catch(SQLException sqle){
System.out.println(sqle.getMessage());
throw new SQLException (sqle.getMessage());
}
catch(Exception e){
System.out.println(e.getMessage());
throw new SQLException (e.getMessage());
}
finally{
cnx.conn.close();
}
return array;
}
}
Meu Servlet (Onde estou tentando iterar o array do DAO):
public class Desossa extends ServletGenerico{
private static final long serialVersionUID = 1L;
@SuppressWarnings("unused")
public void controle() throws SQLException, Exception{
String retorno = "";
VOTeste vo = new VOTeste();
DAOTeste dao = new DAOTeste();
ArrayList array = new ArrayList();
array = dao.dados(vo);
retorno = "/index.jsp";
Iterator iterator = array.iterator();
while (iterator.hasNext()) {
Object elem = iterator.next();
System.out.println("data ="+vo.getData());
System.out.println("valor ="+vo.getValor());
if (elem == null)
elem = "";
}
redireciona(retorno);
}
}
O que estou fazendo de errado pra não estar trazendo os valores do array ???