Connection is busy with results for another hstmt
<p>I am trying to iterate ResultSet values to insert query in while loop.
The code snippet is as follows:</p>

<pre><code>    String sel="select roll_no from Nursery";
    rs=stmt.executeQuery(sel);
    stmt1=con.createStatement();
    int aa;
    while(rs.next())
    {
        aa=rs.getInt(1);
        stmt1.executeUpdate("insert into [Nursery_FirstTerminal_marks](roll_no)values("+aa+")");
        //stmt.close();
    }

    JOptionPane.showMessageDialog(null, "Data has been inserted");
}
    catch(Exception e)
    {
        System.out.println(e);
        // JOptionPane.showMessageDialog(null, e);
    }
</code></pre>

<p>but the below given error is thrown. </p>

<pre><code>java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt
</code></pre>

<p>Can you please suggest how to get out of it..</p>
