title: Spring batch writing to and reading from two databases multiple times
body: <p>I have gotten a batch job where I read frequently from databases, write to '.csv' and right to other databases and these include multiple steps of writing and reading. I have written steps for each phase of writing and reading. The job runs fine with few hundreds of records but when the record becomes large, I got an exception that the reader is unable to read from file as socket is closed. Is there any design strategy you can help me with or example which involves multiple writing and reading from database with <code>csv</code>. Here is my job.</p>
  
  <pre class="lang-java prettyprint-override"><code>    @Bean
      public Job transferDataJob(JobCompletionNotificationListener listener, Step step1, Step step2, Step step3, Step step4, Step step5, Step step6) {
          return jobBuilderFactory
                  .get("transferDataJob")
                  .incrementer(new RunIdIncrementer())
                  .preventRestart()
                  .listener(listener)
                  .start(step1)
                  .next(step2)
                  .next(step3)
                  .next(step4)
                  .next(step5)
                  .next(step6)
                  .build();
      }
  </code></pre>
  
  <p>Here are my steps.</p>
  
  <pre class="lang-java prettyprint-override"><code>    @Bean
      public Step step1() throws  Exception{
          return stepBuilderFactory.get("step1").&lt;Ptrx, Ptrx&gt; chunk(300)
                  .reader(databaseReader())
                  // .processor(processor())
                  .writer(fileWriter())
                  .listener(new StepExecutionListenerSupport())
                  .build();
      }
  
      @Bean
      public Step step2() {
          return stepBuilderFactory.get("step2")
                  .&lt;Ptrx, Ptrx&gt; chunk(300)
                  .reader(reader())
                  //.processor(processor())
                  .writer(writer())
                  .build();
      }
  
      @Bean
      public Step step3() throws Exception{
          return stepBuilderFactory.get("step3")
                  .&lt;Ptrx, Ptrx&gt; chunk(300)
                  .reader(matchedItemReader())
                  //.processor(processor())
                  .writer(matchedItemWriter())
                  .build();
      }
  
      @Bean
      public Step step4() {
          return stepBuilderFactory.get("step4")
                  .&lt;Ptrx, Ptrx&gt; chunk(300)
                  .reader(matchedItemFileReader())
                  //.processor(processor())
                  .writer(matchedItemDbWriter())
                  .build();
      }
  </code></pre>
  
  <p>These are my readers and writers, sorry i had to remove d sql queries</p>
  
  <pre class="lang-java prettyprint-override"><code>    @Bean
      public JdbcCursorItemReader&lt;Ptrx&gt; databaseReader(){
          JdbcCursorItemReader&lt;Ptrx&gt; reader = new JdbcCursorItemReader&lt;&gt;();
          reader.setDataSource(dataSource);
          reader.setSql();
          reader.setRowMapper(new PtrxRowMapper());
  
          return reader;
      }
  
      @Bean
      public FlatFileItemWriter&lt;Ptrx&gt; fileWriter() throws  Exception{
          FlatFileItemWriter&lt;Ptrx&gt; writer = new FlatFileItemWriter&lt;&gt;();
          String rootPath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
          String filePath = rootPath + "ptrx.csv";
          Path path = Paths.get(new URI("file://"+filePath));
          if(path.toFile().exists())
              path.toFile().delete();
              path.toFile().mkdir();
          writer.setResource(new ClassPathResource("ptrx.csv"));
          writer.setLineAggregator(new DelimitedLineAggregator&lt;Ptrx&gt;() {{
              setDelimiter(",");
              setFieldExtractor(new BeanWrapperFieldExtractor&lt;Ptrx&gt;() {{
                  setNames(new String[] { });
              }});
          }});
  
          return writer;
      }
      @Bean
      public JdbcBatchItemWriter&lt;Ptrx&gt; writer() {
          return new JdbcBatchItemWriterBuilder&lt;Ptrx&gt;()
                  .itemSqlParameterSourceProvider(new 
           BeanPropertyItemSqlParameterSourceProvider&lt;&gt;())
                  .sql()
                  .dataSource(dataSource)
                  .build();
      }
  
      @Bean
      public FlatFileItemReader&lt;Ptrx&gt; reader() {
          return new FlatFileItemReaderBuilder&lt;Ptrx&gt;()
                  .name("ptrxItemReader")
                  .resource(new ClassPathResource("ptrx.csv"))
                  .delimited()
                  .names(new String[] {})
                  .fieldSetMapper(new BeanWrapperFieldSetMapper&lt;Ptrx&gt;() {{
                      setTargetType(Ptrx.class);
                  }})
                  .build();
      }
  
      @Bean
      public JdbcCursorItemReader&lt;Ptrx&gt; matchedItemReader(){
          JdbcCursorItemReader&lt;Ptrx&gt; reader = new JdbcCursorItemReader&lt;&gt;();
          reader.setDataSource(dataSource);
      reader.setSql();
          reader.setRowMapper(new PtrxRowMapper());
  
          return reader;
      }
      @Bean
      public FlatFileItemWriter&lt;Ptrx&gt; matchedItemWriter() throws  Exception{
          FlatFileItemWriter&lt;Ptrx&gt; writer = new FlatFileItemWriter&lt;&gt;();
          String rootPath = Thread.currentThread().getContextClassLoader().getResource("").getPath();
          String filePath = rootPath + "matched.csv";
          Path path = Paths.get(new URI("file://"+filePath));
          if(!path.toFile().exists())
              path.toFile().mkdir();
          else {
              path.toFile().delete();
              path.toFile().mkdir();
          }
          writer.setResource(new ClassPathResource("matched.csv"));
          writer.setLineAggregator(new DelimitedLineAggregator&lt;Ptrx&gt;() {{
              setDelimiter(",");
              setFieldExtractor(new BeanWrapperFieldExtractor&lt;Ptrx&gt;() {{
                  setNames(new String[] { });
              }});
          }});
  
          return writer;
      }
  
      @Bean
      public FlatFileItemReader&lt;Ptrx&gt; matchedItemFileReader() {
  
          return new FlatFileItemReaderBuilder&lt;Ptrx&gt;()
                  .name("matchedReader")
                  .resource(new ClassPathResource("matched.csv"))
                  .delimited()
                  .names(new String[] {})
                  .fieldSetMapper(new BeanWrapperFieldSetMapper&lt;Ptrx&gt;() {{
                      setTargetType(Ptrx.class);
                  }})
                  .build();
      }
      @Bean
      public JdbcBatchItemWriter&lt;Ptrx&gt; matchedItemDbWriter() {
      return new JdbcBatchItemWriterBuilder&lt;Ptrx&gt;()
          .itemSqlParameterSourceProvider(new 
      BeanPropertyItemSqlParameterSourceProvider&lt;&gt;())
          .sql()
          .dataSource(dataSource)
          .build();
      }
  </code></pre>
  
  <p>Here is my database configuration</p>
  
  <pre class="lang-java prettyprint-override"><code>@Configuration
  public class DatabaseConfig {
  
      @Bean(name = "datasource1")
      @ConfigurationProperties("database1.datasource")
      @Primary
      public DataSource dataSource(){
          return DataSourceBuilder.create()
                  .build();
      }
  
      @Bean(name = "datasource2")
      @ConfigurationProperties("database2.datasource")
      public DataSource dataSource2(){
          return DataSourceBuilder.create()
                  .build();
      }
  </code></pre>
  
  <p>Here is the stacktrace</p>
  
  <pre><code>2019-10-25 09:48:56.785  INFO 24323 --- [  restartedMain] o.s.b.c.l.support.SimpleJobLauncher      : Job: [SimpleJob: [name=transferDataJob]] launched with the following parameters: [{run.id=135}]
  2019-10-25 09:48:56.803  INFO 24323 --- [  restartedMain] o.s.batch.core.job.SimpleStepHandler     : Executing step: [step1]
  2019-10-25 09:48:56.807  INFO 24323 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Starting...
  2019-10-25 09:48:57.028  INFO 24323 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Start completed.
  2019-10-25 09:48:57.420  INFO 24323 --- [  restartedMain] o.s.batch.core.job.SimpleStepHandler     : Executing step: [step2]
  2019-10-25 09:48:58.176  INFO 24323 --- [  restartedMain] o.s.batch.core.job.SimpleStepHandler     : Executing step: [step3]
  2019-10-25 09:48:58.296  INFO 24323 --- [  restartedMain] o.s.batch.core.job.SimpleStepHandler     : Executing step: [step4]
  2019-10-25 09:48:58.404  WARN 24323 --- [       Thread-2] o.s.b.f.support.DisposableBeanAdapter    : Destroy method 'close' on bean with name 'matchedItemReader' threw an exception: org.springframework.batch.item.ItemStreamException: Error while closing item reader
  2019-10-25 09:48:58.405  WARN 24323 --- [       Thread-2] o.s.b.f.support.DisposableBeanAdapter    : Destroy method 'close' on bean with name 'databaseReader' threw an exception: org.springframework.batch.item.ItemStreamException: Error while closing item reader
  2019-10-25 09:48:58.405  INFO 24323 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Shutdown initiated...
  2019-10-25 09:48:58.412  INFO 24323 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-2 - Shutdown completed.
  2019-10-25 09:48:58.412  INFO 24323 --- [       Thread-2] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
  2019-10-25 09:48:58.414 ERROR 24323 --- [  restartedMain] o.s.batch.core.step.AbstractStep         : Encountered an error executing step step4 in job transferDataJob
  
  org.springframework.batch.item.file.NonTransientFlatFileException: Unable to read from resource: [class path resource [matched.csv]]
      at org.springframework.batch.item.file.FlatFileItemReader.readLine(FlatFileItemReader.java:220) ~[spring-batch-infrastructure-4.1.2.RELEASE.jar:4.1.2.RELEASE]
      at org.springframework.batch.item.file.FlatFileItemReader.doRead(FlatFileItemReader.java:173) ~[spring-batch-infrastructure-4.1.2.RELEASE.jar:4.1.2.RELEASE]
      at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.read(AbstractItemCountingItemStreamItemReader.java:92) ~[spring-batch-infrastructure-4.1.2.RELEASE.jar:4.1.2.RELEASE]
      at org.springframework.batch.core.step.item.SimpleChunkProvider.doRead(SimpleChunkProvider.java:94) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.step.item.SimpleChunkProvider.read(SimpleChunkProvider.java:161) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.step.item.SimpleChunkProvider$1.doInIteration(SimpleChunkProvider.java:119) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:375) ~[spring-batch-infrastructure-4.1.2.RELEASE.jar:4.1.2.RELEASE]
      at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215) ~[spring-batch-infrastructure-4.1.2.RELEASE.jar:4.1.2.RELEASE]
      at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:145) ~[spring-batch-infrastructure-4.1.2.RELEASE.jar:4.1.2.RELEASE]
      at org.springframework.batch.core.step.item.SimpleChunkProvider.provide(SimpleChunkProvider.java:113) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:69) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:407) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:331) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140) ~[spring-tx-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:273) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:82) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:375) ~[spring-batch-infrastructure-4.1.2.RELEASE.jar:4.1.2.RELEASE]
      at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215) ~[spring-batch-infrastructure-4.1.2.RELEASE.jar:4.1.2.RELEASE]
      at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:145) ~[spring-batch-infrastructure-4.1.2.RELEASE.jar:4.1.2.RELEASE]
      at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:258) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:203) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:399) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:135) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:313) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:144) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) [spring-core-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:137) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at com.sun.proxy.$Proxy71.run(Unknown Source) [na:na]
      at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.execute(JobLauncherCommandLineRunner.java:207) [spring-boot-autoconfigure-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.executeLocalJobs(JobLauncherCommandLineRunner.java:181) [spring-boot-autoconfigure-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.launchJobFromProperties(JobLauncherCommandLineRunner.java:168) [spring-boot-autoconfigure-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.run(JobLauncherCommandLineRunner.java:163) [spring-boot-autoconfigure-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:781) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:765) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:319) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at com.activedge.ReconReport.ReconReportApplication.main(ReconReportApplication.java:10) [classes/:na]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
      at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.9.RELEASE.jar:2.1.9.RELEASE]
  Caused by: java.io.IOException: Stream closed
      at java.io.BufferedReader.ensureOpen(BufferedReader.java:122) ~[na:1.8.0_171]
      at java.io.BufferedReader.readLine(BufferedReader.java:317) ~[na:1.8.0_171]
      at java.io.BufferedReader.readLine(BufferedReader.java:389) ~[na:1.8.0_171]
      at org.springframework.batch.item.file.FlatFileItemReader.readLine(FlatFileItemReader.java:201) ~[spring-batch-infrastructure-4.1.2.RELEASE.jar:4.1.2.RELEASE]
      ... 53 common frames omitted
  
  2019-10-25 09:48:58.414  INFO 24323 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
  2019-10-25 09:48:58.419  INFO 24323 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
  2019-10-25 09:48:58.419 ERROR 24323 --- [  restartedMain] o.s.batch.core.step.AbstractStep         : Encountered an error saving batch meta data for step step4 in job transferDataJob. This job is now in an unknown state and should not be restarted.
  
  org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.
      at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:306) ~[spring-jdbc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:378) ~[spring-tx-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:475) ~[spring-tx-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:289) ~[spring-tx-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) ~[spring-tx-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at com.sun.proxy.$Proxy68.updateExecutionContext(Unknown Source) ~[na:na]
      at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source) ~[na:na]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at com.sun.proxy.$Proxy66.updateExecutionContext(Unknown Source) ~[na:na]
      at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:249) ~[spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:399) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:135) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:313) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:144) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50) [spring-core-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:137) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:127) [spring-batch-core-4.1.1.RELEASE.jar:4.1.1.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) [spring-aop-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      at com.sun.proxy.$Proxy71.run(Unknown Source) [na:na]
      at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.execute(JobLauncherCommandLineRunner.java:207) [spring-boot-autoconfigure-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.executeLocalJobs(JobLauncherCommandLineRunner.java:181) [spring-boot-autoconfigure-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.launchJobFromProperties(JobLauncherCommandLineRunner.java:168) [spring-boot-autoconfigure-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.run(JobLauncherCommandLineRunner.java:163) [spring-boot-autoconfigure-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:781) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:765) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:319) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at com.activedge.ReconReport.ReconReportApplication.main(ReconReportApplication.java:10) [classes/:na]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
      at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.9.RELEASE.jar:2.1.9.RELEASE]
  Caused by: java.sql.SQLException: HikariDataSource HikariDataSource (HikariPool-1) has been closed.
      at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:96) ~[HikariCP-3.2.0.jar:na]
      at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:263) ~[spring-jdbc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
      ... 51 common frames omitted
  </code></pre>