title: Spring Batch : HikariPool-1 - Connection is not available, request timed out after 30000ms
body: <p>I've the following error whith SpringBatch :</p>
  <pre><code>org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms.
  </code></pre>
  <p>Given that I've a lot of files to load, I think that the error is because of my TaskExecutor :</p>
  <pre><code>@Bean
      public TaskExecutor MyTE() {
               ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
               executor.setCorePoolSize(64);
               executor.setMaxPoolSize(64);
               executor.setQueueCapacity(64);
               executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
               executor.setThreadNamePrefix(&quot;MyTE-&quot;);
               return executor;
          }
  </code></pre>
  <p>I used &quot;Integer.MAX_VALUE&quot; for CorePoolSize, MaxPoolSize  and QueueCapacity (instead of 64) but the error occurs all the same.</p>
  <p>Edit : Eventually, the cause of my problem seems to be a call to a stored procedure
  in beforeJob. Indeed, when I comment this code below, it works.</p>
  <pre><code>@Override
  public void beforeJob(JobExecution jobExecution) {
          
  CallableStatement cs=null; 
  
  cs=MyDataSource.getConnection().prepareCall(&quot;CALL my_proc(?,?)&quot;);
  cs.setString(1, &quot;my_arg1&quot;);
  cs.setString(2,&quot;my_arg2&quot;); 
  cs.execute();
  cs.close();
  </code></pre>
  <p>However, I want to do this call and I don't understand why it generates a problem. Connection seems to be well closed with <code>cs.close();</code></p>
  <p>What is the problem ?</p>
  <p>Regards.</p>
  <p><strong>Solution :</strong></p>
  <pre><code>Connection con = null;
  CallableStatement cs = null; 
  
  con=MyDataSource.getConnection();
                           
  cs=con.prepareCall(&quot;CALL my_proc(?,?)&quot;);
  cs.setString(1, &quot;my_arg1&quot;);
  cs.setString(2,&quot;my_arg2&quot;); 
  cs.execute();
  
  cs.close();
  con.close();
  </code></pre>