title: JDBCTemplate setQueryTimeout specific for each query i.e, Query Level
body: <p>I need to set query timeout for various ranges of queries depending on the data they pull. ie, each query will have their own timeout time.  </p>
  
  <p>say for instance, query A - > 10 MINUTES<br>
                    query B - > 5 MINUTES  </p>
  
  <p>Now how do I set these different timings using the getJDBCTemplate(). When I try the below code snippet, the timeout is overidden and both the queries are timing out on the same time irrespective of the setting!  </p>
  
  <pre><code>Thread t1 = new Thread(new Runnable() {
  public void run() {
         getJdbcTemplate().setQueryTimeout(5);
         List t = getJdbcTemplate()
                     .query("select top 10000 * from ABC",new RowMapper&lt;T&gt;(){
                     ..
         });
  
  Thread t2 = new Thread(new Runnable() {
  public void run() {
         getJdbcTemplate().setQueryTimeout(10);
         List t = getJdbcTemplate()
          .query("select top 30000 * from XYZ",new RowMapper&lt;T&gt;() {
                          ..
         });
  t1.start();
  t2.start();  
  </code></pre>
  
  <p>In the above context, both the queries are timing out at 5th min or 10th min. Is there a way to set it up based on the query ? please suggest!</p>
  
  <p><strong>[UPDATE]</strong></p>
  
  <pre><code>&lt;bean id="dSource" class="com.xyz.DSource" &gt;
      &lt;property name="dataSource" ref="dataSource"/&gt;
  &lt;/bean&gt;
  
  public abstract class AbstractData  {
      private DSource dSource;
      public JdbcTemplate getJdbcTemplate(){
  
          ApplicationContext Ctx = ContextUtils.getApplicationContext(); 
          dSource = (DSource)Ctx.getBean("dSource");
          return dSource.getJDBCTemplate();
           }
  }
  
  public class DSource extends JdbcDaoSupport{
      public JdbcTemplate getJdbcTemplate(){
          return getJdbcTemplate();
      }
  }
  
  public Class Dao extends AbstractData{
       public void callQuery(){
          [AS already posted, t1 and t2 are 2 threads for 2 diff methods/queries using 
           getJDBCTemplate Of abstract classs]
  
         Thread 1 
         Thread 2
       }
  
  }
  </code></pre>