I am using Spring Boot 1.5.17 with multiple data sources configured. One of my data sources is configured as follows.
@Primary
@Bean
@ConfigurationProperties("app.primary.datasource")
public DataSource primaryDataSource() {
return DataSourceBuilder.create().build();
}
Now how do I get or log the number of active connections in the connection pool for this data source?
It's a bit late , but DataSource interface doesn't have any methods that lets you do this, but if you are using HikariCP (which is the default).
You could do this.