title: How can I cancel a long-running query using Spring and JDBCTemplate?
body: <p>The JDBC <code>java.sql.Statement</code> class has a <code>cancel()</code> method. This can be called in another thread to cancel a currently running statement.</p>
  
  <p>How can I achieve this using Spring? I can't find a way to get a reference to a statement when running a query. Nor can I find a cancel-like method.</p>
  
  <p>Here's some sample code. Imagine this takes up to 10 seconds to execute, and sometimes on the user's request, I want to cancel it:</p>
  
  <pre><code>    final int i = simpleJdbcTemplate.queryForInt("select max(gameid) from game");
  </code></pre>
  
  <p>How would I modify this so I have a reference to a <code>java.sql.Statement</code> object?</p>