title: JDBC Connection taking too long
body: <p>I have an issue in my Spring MVC JDBC call. If I make the call quickly after starting the server, the JDBC connection is make in a second and the data is retrieved. Similarly, if the other DAOs are called in quick succession with one another, the connection is made soon. But if I try to call a DAO after a gap of even a few minutes, the JDBC connection takes forever to be done. It gets stuck on </p>
  
  <blockquote>
    <p>"DataSourceUtils:110 - Fetching JDBC Connection from DataSource"</p>
  </blockquote>
  
  <p>I have never had the patience to really check how long it takes to retrieve the connection but I've waited for 10 minutes and there was no sign of the connection being made.</p>
  
  <p>Next, I try to restart the server at least. But JDBC obstructs even stopping of the server!! The console is stuck on this line:</p>
  
  <blockquote>
    <p>"DisposableBeanAdapter:327 - Invoking destroy method 'close' on bean with name 'dataSource'"</p>
  </blockquote>
  
  <p>Eventually I restart Eclipse and it works alright until there is a time gap again. </p>
  
  <p>This is my bean definition for the data source:</p>
  
  <pre><code>&lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
          destroy-method="close"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
      &lt;property name="url" value="url" /&gt;
      &lt;property name="username" value="abc" /&gt;
      &lt;property name="password" value="abc" /&gt;
      &lt;property name="validationQuery" value="SELECT 1" /&gt;
      &lt;property name="testWhileIdle" value="true" /&gt;
      &lt;property name="maxActive" value="100" /&gt;
      &lt;property name="minIdle" value="10" /&gt;
      &lt;property name="initialSize" value="10" /&gt;
      &lt;property name="maxIdle" value="20" /&gt;
      &lt;property name="maxWait" value="1000" /&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;
  
  &lt;bean id="getDataDao" class="com.project.dao.GetDataDao"&gt;
      &lt;constructor-arg index="0" ref="jdbcTemplate" /&gt;
      &lt;constructor-arg index="1" value="STORED_PROC_NAME"&gt;&lt;/constructor-arg&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>In my DAO file, I extend Spring's StoredProcedure class and this is the constructor:</p>
  
  <pre><code>public GetDataDao(JdbcTemplate jdbcTemplate, String spName) {
  
          super(jdbcTemplate, spName);
  
          declareParameter(new SqlParameter("p_input", Types.VARCHAR));
          declareParameter(new SqlOutParameter("o_result", Types.VARCHAR));
  
          compile();
      }
  </code></pre>
  
  <p>In another function, this is how I call the SP:</p>
  
  <pre><code>spOutput = super.execute(spInput);
  </code></pre>
  
  <p>where <code>spOutput</code> and <code>spInput</code> are HashMaps.</p>
  
  <p>Am I doing something wrong in my configuration? TIA.</p>