Results 1 to 2 of 2
  1. #1
    Join Date
    May 2006

    Unanswered: Multiple statements in resultset not working

    Hi everyone,

    I have a JSP web form that ties into a database. I am trying to process to statements inside a resultset loop, but cannot get it to work. I looks relatively simple, but I don't understand it. Can someone show me how or what I am doing wrong or how this could be fixed? I appreciate it. -Regards.

    Statement stmt = conn.createStatement();

    String id = request.getParameter("ID");

    resultSet rs = stmt.executeQuery(" SELECT * FROM myTable1 WHERE id='skjones' ");

    while( {
    String name = rs.getString("USERNAME");
    String location = rs.getString("REGION");

    stmt.executeUpdate("INSERT INTO myTable2 (EMPLOYEE, SITE) VALUES (' + name + , + location + ) );


    Last edited by sonny105; 05-12-06 at 12:47. Reason: incorrect wording

  2. #2
    Join Date
    Apr 2003
    When you use the Statement again your ResultSet disappears (or rather is filled with the results of the new statement you executed, in this case nothing).

    Create a new Statement for your updates.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts