title: Execute multiple queries using a single JDBC Statement object
body: <p>In JDBC, can I use single <code>Statement</code> object to call <code>executeQuery(&quot;&quot;)</code> multiple times? Is it safe? Or should I close the statement object after each query, and create new object for executing another query.</p>
  <p>E.G:</p>
  <pre><code>Connection con;
  Statement s;
  ResultSet rs;
  ResultSet rs2;
  try
  {
      con = getConnection();
      // Initially I was creating the Statement object in an
      // incorrect way. It was just intended to be a pseudocode.
      // But too many answerers misinterpretted it wrongly. Sorry 
      // for that. I corrected the question now. Following is the 
      // wrong way, commented out now. 
      // s = con.prepareStatement();
      
      // Following is the way which is correct and fits for my question.
      s = con.createStatement();
  
      try
      {
          rs = s.executeQuery(&quot;.......................&quot;);
  
          // process the result set rs
      }
      finally
      {
          close(rs);
      }
  
      // I know what to do to rs here
      // But I am asking, should I close the Statement s here? Or can I use it again for the next query?
  
      try
      {
          rs2 = s.executeQuery(&quot;.......................&quot;);
  
          // process the result set rs2
      }
      finally
      {
          close(rs2);
      }
  }
  finally
  {
      close(s);
      close(con);
  }
  </code></pre>