title: Where to close statements in JDBC
body: <p>I am using JDBC to retrieve data from a database. I understand that a Statement needs to be closed after it is used. However, I keep run into the same error telling me that no operation is allowed after the statement is closed. The structure of my code is like</p>
  
  <pre><code>public void foo() {
  
  Statement;
  try {
  } catch{
  }
  Statement.close();
  }
  </code></pre>
  
  <p>In my code, I need to call this function repeatedly. I was wondering where to close the Statement.</p>
  
  <p>Thanks</p>