Hello Javier,
I have not used ResultSets yet but I think you will need to use rs.hasNext()
as your loop variable, this returns a boolean telling you whether there is
another value in the result set.
Then use rs.next() to assign the data to a local object within the loop and
access the method through this new object.
ie
while( rs.hasNext() ) {
ObjectType local = rs.next();
Noticias temp = new Noticias();
temp=null;
temp.setCod_noticia(local.getFloat("cod_noticias"));
}
Otherwise the pointer in your iterator will eventually point to a null value
at the end of the resultset, giving you the NullPointerException which is
not caught. hasNext does not throw this exception, instead it should just
return a false value.
or do the assign within your while loop condition
ie
while( ObjectType local = rs.next() ) {
// do all
}
Hope this helps,
Mike
> //Todav�a no hay columna negocio.
> "FROM EROSKI_NOTICIAS ORDER BY fechanoticia");
> //vectorNoticias = new Vector();
> while (rs.next()) {
> Noticias temp = new Noticias();
> temp=null;
> temp.setCod_noticia(rs.getFloat("cod_noticias"));
> temp.setDestacado(rs.getString("destacado"));
> temp.setEntradilla(rs.getString("entradilla"));
> temp.setEntradillaCat(rs.getString("entradillacat"));
> temp.setEntradillaEus(rs.getString("entradillaeus"));
> temp.setEntradillaGal(rs.getString("entradillagal"));
> temp.setEntradillaIng(rs.getString("entradillaing"));
> temp.setEntradillaVal(rs.getString("entradillaval"));
> temp.setFecha(rs.getString("fecha"));
> // temp.setNegocio(rs.getString("negocio"));
> // Todav�a no tenemos columna negocio
> temp.setTexto(rs.getString("texto"));
> temp.setTextoCat(rs.getString("textocat"));
> temp.setTextoEus(rs.getString("textoeus"));
> temp.setTextoGal(rs.getString("textogal"));
> temp.setTextoVal(rs.getString("textoval"));
> temp.setTitulo(rs.getString("titulo"));
> temp.setTituloCat(rs.getString("titulocat"));
> temp.setTituloEus(rs.getString("tituloeus"));
> temp.setTituloGal(rs.getString("titulogal"));
> temp.setTituloIng(rs.getString("tituloing"));
> temp.setTituloVal(rs.getString("tituloval"));
> temp.setAnyo(rs.getString("anyo"));
> temp.setMes(rs.getString("mes"));
> //Ahora a�ado todo al vector
> vectorNoticias.addElement(temp);
> }
> } catch (SQLException sql) {
> System.out.println("Se ha producido un error SQL");
> System.out.println(sql.getMessage());
> } finally {
> if (st != null) {
> try {
> st.close();
> } catch (SQLException e) {
> System.out.println("Se ha producido un error al cerrar la conexion");
> System.out.println(e.getMessage());
> }
> }
> }
> }
>
>
> Javier
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html