You can use resultado.getString(1) only one time.
Try String Something=resultado.getString(1);
out.println(Something);
....
out.println("<h2>"+Something+"</h2>");
Hope to help you
Regards Rinaldo
-----Messaggio originale-----
Da: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]] Per conto di
Daniel Cabrera Solana
Inviato: luned� 22 ottobre 2001 12.46
A: [EMAIL PROTECTED]
Oggetto: Re: ResultSet.getString() problem
Sorry!!, In my original code the second call to resultado.getString(1)
is before mas =resultado.next() and I have the same problem. I don't
understand why. In theory the cursor must be in the same position and I
must be able to call many times to this function..... I don't understand
what is�s wrong...
Best Regards, Daniel
Thanks a million
----- Original Message -----
From: I Wayan Saryada <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 22, 2001 12:39 PM
Subject: Re: ResultSet.getString() problem
> Hi....
>
> When you call the second "resultado.getString(1)" in your while loop
> it might that there is not record on the resultset. Why? because
> you've called "mas = resultado.next()" which tell to go to next item
> in the resultset, and if at that time the resultset is already at the
> end, you have no record to access and of course it will raise
> exception.
>
> So instead you have to do it like this:
>
> while (resultado.next()) {
> ......
> ...... // do what you need here....
> ......
> }
>
> so when the resultado.next() return false the process won't enter the
> while loop.
>
> Hope this can help,
>
> Regards,
> Wayan
>
>
> -----Original Message-----
> From: Daniel Cabrera Solana [mailto:[EMAIL PROTECTED]]
> Sent: Monday, October 22, 2001 5:52 PM
> To: [EMAIL PROTECTED]
> Subject: ResultSet.getString() problem
>
>
> Hi all:
>
> I am doing queries against a bd. After I show the ResultSet in
> tables (HTML). I have a problem with the ResultSet.getString(). It
> seems like I only can call this function once. If I call twice I hava
> errors like: -No data found
>
> Do you know if this function take the data of the ResultSet?.
> (Perhaps after the first call the registry is empty....)
>
>
> This is more or less the code:
>
> Connection conexion;
> Statement sentencia;
> ResultSet resultado;
> boolean mas;
> String driver = "jdbc:odbc:prueba";
> String usuario = "prueba";
> String clave = "prueba";
>
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> conexion = DriverManager.getConnection(driver,usuario,clave);
> sentencia = conexion.createStatement();
> resultado = sentencia.executeQuery("select columna1,columna2 from
> tabla");
>
>
> mas = resultado.next();
>
> out.println("<html><body>");
> out.println("<table>");
>
> while(mas){
> out.println("<tr>");
> out.println("<td>");
> out.println(resultado.getString(1));
> out.println("</td>");
>
> out.println("<td>");
> out.println(resultado.getString(2));
> out.println("</td>");
>
> out.println("</table>");
>
> mas = resultado.next();
>
> /*HERE COMES THE PROBLEM!!!!!!!*/
>
> out.println("<h2>"+resultado.getString(1)+"</h2>");
>
> out.println("</body></html>")
> }
>
> Do you what is the problem with this second call??
>
>
> Thanks a million, Daniel
>
>
________________________________________________________________________
___
> 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
___________________________________________________________________________
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