title: PostgreSQL connections still idle after close in JDBC
body: <p>I am New to SpringBoot.</p>
  <p>I have a Spring Boot Application and the Database I am using is PostgreSQL, I am using JdbcTemplate and I have 2 datasource connections.
  The code works fine,but I observed that in PostgreSQL pgAdmin in the Server Status Dashboard,it shows the connection pool(Say 10 connection) in idle mode.
  While earlier I was working with single datasource, I observed the same thing,but I solved it by setting some properties within application.properties file.
  For.e.g:</p>
  <pre><code>         spring.datasource.hikari.minimum-idle=somevalue
  
           spring.datasource.hikari.idle-timeout=somevalue
  </code></pre>
  <p>How do I achieve the same with multiple Datasources.</p>
  <p>properties file</p>
  <pre><code>spring.datasource.jdbcUrl=jdbc:postgresql://localhost:5432/stsdemo
  spring.datasource.username=postgres
  spring.datasource.password=********
  spring.datasource.driver-class-name=org.postgresql.Driver
  
  
  spring.seconddatasource.jdbcUrl=jdbc:postgresql://localhost:5432/postgres
  spring.seconddatasource.username=postgres
  spring.seconddatasource.password=********
  spring.seconddatasource.driver-class-name=org.postgresql.Driver
  </code></pre>
  <p>DbConfig</p>
  <pre><code>@Configuration
  public class DbConfig {
  
      @Bean(name=&quot;db1&quot;)
       @Primary
      @ConfigurationProperties(prefix=&quot;spring.datasource&quot;)
      public DataSource firstDatasource()
      {
           return DataSourceBuilder.create().build();
      }
      
      
       @Bean(name = &quot;jdbcTemplate1&quot;)
       public JdbcTemplate jdbcTemplate1(@Qualifier(&quot;db1&quot;) DataSource ds) {
        return new JdbcTemplate(ds);
       }
       
       @Bean(name=&quot;db2&quot;)
       @ConfigurationProperties(prefix=&quot;spring.seconddatasource&quot;)
       public DataSource secondDatasource()
       {
           return DataSourceBuilder.create().build();
       }
      
       @Bean(name=&quot;jdbcTemplate2&quot;)
       public JdbcTemplate jdbcTemplate2(@Qualifier(&quot;db2&quot;) DataSource ds)
       {
           return new JdbcTemplate(ds);
       }
  }
  </code></pre>