Insert Query is inserting only first row from the result set in the database table
<p>I am fetching records from table EmployeeLeave and storing it in a result set. Then I am inserting this result set in a database table but I am able to insert only the first row of the result set instead of all the rows.<br>
How can i insert all the rows of the result set?</p>

<pre><code>r = stmt.executeQuery("select * from EmployeeLeave where EmployeeNo='"+empno+"'");
while(r.next())
{
    for(int i=0;i&lt;=r.getRow();i++)
    {
        int empid = r.getInt(1);
        String leave = r.getString(2);
        r = stmt.executeQuery("insert into ApprovedLeave values('"+empid+"','"+leave+"','True')");
    }
}
</code></pre>
