title: Java generating query from resultSet and executing the new query
body: <p>I am trying to use some query result to generate another query and execute the new query but that does not seem to work. The second query is not being executed. Can someone please tell me why? This is that part of the code.</p>
  
  <pre><code>Statment stmt = connnection.createStatement();
  Statment stmt2 = connnection.createStatement();
  ResultSet r =  stmt.executeQuery("Select * from employees");
  while (r.next()) {
              String Str = "Select name from employees where employeeId = " + (r.getInt(3) + 1);
              System.out.println(str);
              query = stmt2.executeQuery(str);
              System.out.println(query.getString(1));}
  </code></pre>
  
  <p>The right query seems to be generated, but just won't execute. Is there a reason why this is so. BTW "query" is declared as resultset.
  Thanks</p>