What is the default value used for maximum connections on a postgres
database with tomcat
connection pooling using spring-boot
?
There is a property spring.datasource.maxActive
, but when I try to sysout it, I'm getting an exception:
@Value("${spring.datasource.maxActive}")
private String act;
java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.maxActive' in string value "${spring.datasource.maxActive}
The default connection pool in Spring Boot 2 is HikariCP. It provides enterprise-ready features and better performance. HikariCP is a JDBC DataSource implementation that provides a connection pooling mechanism. If the HikariCP is present on the classpath, the Spring Boot automatically configures it.
The Tomcat Connection pool is configured as a resource described in The Tomcat JDBC documentation With the only difference being that you have to specify the factory attribute and set the value to org.apache.tomcat.jdbc.pool.DataSourceFactory.
Connection pooling is a well-known data access pattern. Its main purpose is to reduce the overhead involved in performing database connections and read/write database operations.
Hikari is a JDBC DataSource implementation that provides a connection pooling mechanism. Compared to other implementations, it promises to be lightweight and better performing. For an introduction to Hikari, see this article.
According to org.apache.tomcat.jdbc.pool.PoolProperties
the default value is 100
You need to set spring.datasource.max-active in your application.properties or application.yaml to get the value in your bean class
Refer https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html for common application.properties
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