Using application.properties we can provide the
spring.datasource.hikari.maximum-pool-size=10
as spring using the Hikari connection pooling by default. But when we are creating datasource manually as a specific requirement we cannot use the application.properties.
Scenario.
- User will configure the datasource dynamically and that connection object should be available from thereafter.
- For this we are creating DatasourceBuilder.create().build() method to create a datasource connection object and set it into the bean factory.
- But while creating a datasource connection object using DataSourceBuilder.create().build() method it is creating connection pooling and 10 connection to the database at the same time.
- We wanted to avoid that connection pooing and have only one connection.
How do I do that?