I have a PostgreSQL 11 server with pgBouncer pooling set up and enabled.
I'd like to use its pooling mechanism rather than default Hikari and Tomcat pooling that come with the Spring Boot's spring-boot-starter-data-jpa
. I've disabled HikariCP
and tomcat-jdbc
from the project however, I'm not sure what I'd need to set up further in order to launch the Spring app successfully.
I guess my question is how to set up a Spring application so that it doesn't use any pooling mechanism to communicate with the db as it will be handled by pgBouncer
on the db side?
I have looked at a variety of questions and answers to somewhat similar questions which led to me disabling HikariCP
to start with. However, I was unable to find a concise tutorial/example of how I could make this work in my case scenario.
Any help would be really appreciated.
I had similar problem, and after looking at the spring source codes I found an easier way that does not require any code or pom changes.
spring:
datasource:
type: org.springframework.jdbc.datasource.DriverManagerDataSource
driver-class-name: org.postgresql.Driver
This datasource will simply replace hikari and create a new connection every time instead of pooling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With