Hi Javier,

seems like your requesting a column which is not within your resultset.
For testing and debugging you may try this sketched approach (please 
check method names, I did my best to recall them correct :-) )
stmt = conn.createStatment();
rs = stmt.execute("...");
ResultSetMetaData rsMeta = rs.getMetaData();
System.out.println("Columns in rs: "+rsMeta.getColumnCount());
for(int i = 1; i <= rsMeta.getColumnCount(); i++) {
 System.out.println(rsMeta.getColumnName(i));
}

This prints all available column names in your result set.
Then it's easy to check your code.
Importand: 
1.The loop above MUST start with index 1!!!! This is JDBC ploicy, all 
indexes in JDBC start with 1. for that reason the for-predicate is a <= 
expression.
2.Calling rs.getMetaData() might be time consuming, better avoid if 
possible!

Peter

----- Original Message -----
From: Javier Alonso <[EMAIL PROTECTED]>
Date: Tuesday, November 20, 2001 10:43 am
Subject: Help at putting the Result Set in a Vector.

> Hello everyone. I�m still having problems with the 
> BuscarNoticiasServlet i
> posted.
> THe problem is with the ResultSet thing.First i made another class 
> just to
> set some variable and get their values. Its a public class in the same
> package.
> Now after making the SQL connection and statement i�m trying to 
> get my
> restulset and making a loop with it in this way:
> 
> /**
> * Insert the method's description here.
> * Creation date: (09/11/01 13:56:10)
> */
> public void obtenerNoticias() {
> Statement st;
> st=null;
> vectorNoticias=new Vector();
> System.out.println("Ahora vamos a por la SQL");
> ResultSet rs;
> rs=null;
>  try {
>  st = conn.createStatement();
>  rs = st.executeQuery("SELECT * FROM SYSTEM.EROSKI_NOTICIAS ORDER BY
> fechanoticia");
>   System.out.println("SQL OBTENIDA");
>    while (rs.next()) {
> 
>   Noticias temp = new Noticias();
>   temp=null;
>   System.out.println("Empezamos a fijar los datos de temp");
>      System.out.println(rs.getFloat("cod_noticia"));
>   //temp.setCod_noticia(rs.getFloat("cod_noticia"));
>   //temp.cod_noticia=rs.getFloat("cod_noticia");
>   System.out.println("OK");
>   System.out.println(rs.getString("destacado"));
>   System.out.println(rs.getString("TITULO"));
>   //String pdestacado=rs.getString("destacado");
>   //Noticias temp = new
> Noticias(rs.getString("destacado"),rs.getString("titulo"));
> 
> 
>   System.out.println("Un campo fijado");
>   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"));*/
>     System.out.println("ahora llego al vector");
>   vectorNoticias.addElement(temp);
> //   mostarNoticias(resp,idioma);
>  }
> } 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());
>   }
>  }
> }
> 
> }
> 
> First: I dont get in the console the variable TITULO (a String) 
> and anyway i
> get a SQL exception : "NO data found " or another one "Invalid 
> Column number
> <2>" (the TITULO column). ANy help? Thanks.
> I�ll also thank you if you can tell me where can i get a good 
> debugger (the
> Visual Age  debugger doesnt works with servlets cause they�re not 
> applets or
> runnable). Thanks a lot
> 
>        JAvi
> 
> 
________________________________________________________________________
___
> To unsubscribe, send email to [EMAIL PROTECTED] and include in 
> the body
> of the message "signoff SERVLET-INTEREST".
> 
> Archives: http:
> Resources: http://java.sun.com/products/servlet/external-
> resources.htmlLISTSERV 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

Reply via email to