looping problem while appending data to existing text file
<pre><code>     try {
     stmt = conn.createStatement();
     stmt1 = conn.createStatement();
     stmt2 = conn.createStatement();
     rs = stmt.executeQuery("select cust from trip1");
     rs1 = stmt1.executeQuery("select cust from trip2");
     rs2 = stmt2.executeQuery("select cust from trip3");
      File f = new File(strFileGenLoc);
      OutputStream os = (OutputStream)new FileOutputStream(f,true);
      String encoding = "UTF8";
      OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
      BufferedWriter bw = new BufferedWriter(osw);


 }


       while ( rs.next() ) {

         while(rs1.next()){

              while(rs2.next()){

         bw.write(rs.getString(1)==null? "":rs.getString(1));
             bw.write("\t");
         bw.write(rs1.getString(1)==null? "":rs1.getString(1));
         bw.write("\t");
         bw.write(rs2.getString(1)==null? "":rs2.getString(1));
         bw.write("\t");

         bw.newLine();

              }
         }
     }
</code></pre>

<p>Above code working fine.
 My problem is 
   1. "rs" resultset contains one record in the table
   2. "rs1" resultset contains 5 record in the table
   3. "rs2" resultset contains 5 record in the table</p>

<p>"rs" data is getting recursive.</p>

<p>while writing to the same text file , the output i am getting  like </p>

<pre><code>1   2    3
1   12   21
1   23   25
1   10   5
1   8    54
</code></pre>

<p>but i need output like below</p>

<pre><code>1   2    3
   12   21
   23   25
   10   5
    8    54
</code></pre>

<p>What things i need to change in my code.. Please advice</p>
