If you want to show twice the first column of the ResultSet (resultado.getString(1)), you must do it before calling resultado.next(). Otherwise when the ResultSet gets the last row of your query, it tries to get the value of the column 1 of a row that doesn't exist.
Calling resultado.next() the cursor of the resultset is going to the following row. I think a best solution is calling the next method in the while. Doing so you'll never have any problem. Carlos -----Mensaje original----- De: Daniel Cabrera Solana [mailto:[EMAIL PROTECTED]] Enviado el: lunes 22 de octubre de 2001 11:52 Para: [EMAIL PROTECTED] Asunto: 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
