title: DBUtils QueryRunner instantiation
body: <p>I have a webservice that instantiates a single <a href="http://commons.apache.org/dbutils/apidocs/org/apache/commons/dbutils/QueryRunner.html" rel="noreferrer">QueryRunner</a> with a data source on initialization. It uses this one <code>QueryRunner</code> object for all servlet requests from multiple different servlets used by the webapp by passing it around as a servlet context attribute. I.e.:</p>
  
  <pre><code>// in servlet context listener (on app initialization)
  QueryRunner myQueryRunner = new QueryRunner(myDataSource);
  myServletContext.setAttribute("queryRunner", myQueryRunner);
  
  // in the servlets
  QueryRunner myQueryRunner = (QueryRunner) myServletContext.getAttribute("queryRunner");
  myQueryRunner.query(myStoredProcedure, handler, params)
  </code></pre>
  
  <p>I am trying to figure out if that is a bottleneck. Should the servlets be instantiating a new <code>QueryRunner</code> with every request instead?</p>
  
  <p>When looking around for an answer I also found this <a href="http://commons.apache.org/dbutils/apidocs/org/apache/commons/dbutils/AsyncQueryRunner.html" rel="noreferrer">AsyncQueryRunner</a>. But I just got more confused because the explanations in the API docs for <a href="http://commons.apache.org/dbutils/apidocs/org/apache/commons/dbutils/QueryRunner.html" rel="noreferrer">QueryRunner</a> and <a href="http://commons.apache.org/dbutils/apidocs/org/apache/commons/dbutils/AsyncQueryRunner.html" rel="noreferrer">AsyncQueryRunner</a> say the exact same thing. </p>
  
  <p>I looked through the examples <a href="http://commons.apache.org/dbutils/examples.html" rel="noreferrer">here</a> and it seems that it should be instantiated with every request but I am not sure if that is just because it is example code.</p>
  
  <p>In other words, when using DBUtils <code>QueryRunner</code> should I:</p>
  
  <ol>
  <li>Use a single <code>QueryRunner</code> instance for every request? (what I am
  doing now)</li>
  <li>Instantiate a new <code>QueryRunner</code> with every servlet request?</li>
  <li>Use a single <code>AsyncQueryRunner</code> instance for every request?</li>
  </ol>