title: Cannot create my Spring Batch tables in a different schema in Postgres
body: <p>I have a Spring Boot app that uses Hibernate and Spring Batch. I am using PostgresSQL for my backend database.</p>
  <p><strong>My project has 2 different data sources configured.</strong> <strong>One for Hibernate and one for Spring Batch.</strong> They are both in the same database <strong>but in different schemas.</strong></p>
  <p>My spring batch connection string is the following:</p>
  <pre><code>spring.batch.datasource.url=jdbc:postgresql://localhost:5432/mytestapp?currentSchema=springbatch 
  </code></pre>
  <p>I have the Datasource configured in the following way:</p>
  <pre><code>@Bean(&quot;b_ds_prop&quot;)
      @ConfigurationProperties(&quot;spring.batch.datasource&quot;)
      public DataSourceProperties dataSourceProperties() {
          return new DataSourceProperties();
      }
  
      @Bean(&quot;b_ds&quot;)
      @DependsOn({&quot;b_ds_prop&quot;})
      public DataSource batchFrameworkDatasource(DataSourceProperties dataSourceProperties) {
          System.out.println(&quot;start print&quot;);
  //      dataSourceProperties.getSchema().stream().forEach(System.out::println);
  //      System.out.println(&quot;datasrcprop is null : &quot; + (dataSourceProperties==null));
  //      System.out.println(&quot;datasrcprop.schema is null : &quot; + (dataSourceProperties.getSchema()==null));
          System.out.println(&quot;end print&quot;);
  //      dataSourceProperties.setSchema(Arrays.asList(&quot;spring_batch&quot;));
          return dataSourceProperties.initializeDataSourceBuilder().build();
      }
      
      @Bean
      @DependsOn({&quot;b_ds&quot;})
      public BatchConfigurer defaultBatchConfigurer(@Qualifier(&quot;b_ds&quot;) DataSource dataSource) {
          return new DefaultBatchConfigurer(dataSource);
      }
  </code></pre>
  <p><strong>The <code>currentSchema=springbatch</code> setting is not respected, no matter what I do.</strong> All my Spring Batch tables keep ending up in <code>public</code> in Postgres.</p>
  <p>The schema named <code>springbatch</code> is already present in my database : <code>mytestapp</code>.</p>
  <p>I have tried <code>currentSchema=springbatch, public</code>, I have even tried <code>spring.batch.table-prefix=springbatch.</code>.</p>
  <p>I have tried everything, <strong>but still I cannot understand why my batch tables keep ending up in the <code>public</code> schema.</strong></p>
  <p><strong>Please note I have another connection string in my project like:</strong></p>
  <pre><code>spring.hib.datasource.url=jdbc:postgresql://localhost:5432/mytestapp
  </code></pre>
  <p>I have also tried programmatically checking what is the value of <code>schema</code> in <code>DataSourceProperties</code>.</p>
  <pre><code>System.out.println(&quot;datasrcprop.schema is null : &quot; + (dataSourceProperties.getSchema()==null));
  </code></pre>
  <p>This evaluates to true.</p>
  <p><strong>How can I set the schema to be different for Spring Batch ?</strong></p>
  <p>Any help would be great.</p>
  <p>Thanks.</p>