title: spring JDBC Template: fetching jdbc connection
body: <p>I use Spring Jdbc template to acquire database Connection.
  here is my dispatcher.xml config</p>
  
  <pre><code>&lt;bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close"&gt;
          &lt;property name="driverClassName" value="com.cloudera.impala.jdbc4.Driver" /&gt;
          &lt;property name="url"
              value="jdbc:impala://IP:Port/DatabaseName;auth=noSasl" /&gt;
          &lt;property name="username" value="" /&gt;
          &lt;property name="password" value="" /&gt;
          &lt;property name="timeBetweenEvictionRunsMillis" value="50000" /&gt;
          &lt;property name="validationQuery" value="SELECT 1"/&gt;
          &lt;property name="initialSize" value="10" /&gt;
          &lt;property name="minIdle" value="10" /&gt;
          &lt;property name="maxActive" value="100" /&gt;
          &lt;property name="jmxEnabled" value="true" /&gt;
          &lt;property name="testOnBorrow" value="true"/&gt;
          &lt;property name="testOnConnect" value="true"/&gt;
          &lt;property name="testOnReturn" value="true"/&gt; 
  &lt;/bean&gt;
  &lt;bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>and i use jdbcTemplate for executing my query as autowird Object as well as NamedParameterJdbcTemplate via new NamedParameterJdbcTemplate(datasource)</p>
  
  <p>NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);</p>
  
  <p>while fetching JDBC Connection it takes too long or fails some times, should i use an autowired object for "NamedParameterJdbcTemplate" Object, i dont know where the connection leaks occure.</p>
  
  <p>Thanks, 
  Siva</p>