2

I am trying to set schema to dataSource object as below in Java based configurations.

@Bean(name = "dataSource")
    public DataSource dataSource() 
    {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName(driverClassName);
        dataSource.setUrl(jdbcURL);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        Properties connectionProperties = new Properties();
        connectionProperties.setProperty("testOnBorrow", "true");
        connectionProperties.setProperty("validationQuery", "SELECT 1");
        connectionProperties.setProperty("spring.datasource.schema", "schemaname");
        dataSource.setConnectionProperties(connectionProperties);
        return dataSource;
    }

But it doesn't seems to be set as it always searches for tables in public schema. FYI, I am using Spring JDBC and Postgres as database.

Please do help me on above.

raju vaishnav
  • 751
  • 1
  • 6
  • 17
  • 1
    Did you try to set the schema in the jdbcURL as explained in http://stackoverflow.com/questions/4168689/is-it-possible-to-specify-schema-when-connecting-to-postgres-with-jdbc ? – Val Bonn Jan 02 '17 at 09:35
  • @ValBonn, yes i did try, but it didn't work. it searches for tables in public schema.. – raju vaishnav Jan 02 '17 at 09:37

0 Answers0