Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default connection pool for tomcat in spring-boot?

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}

like image 454
membersound Avatar asked Feb 17 '16 09:02

membersound


People also ask

What is the default connection pool in spring boot?

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.

What is connection pool in Tomcat?

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.

What is connection pooling in Java Spring boot?

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.

What is Hikari connection pool in spring boot?

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.


2 Answers

According to org.apache.tomcat.jdbc.pool.PoolProperties the default value is 100

like image 50
WeMakeSoftware Avatar answered Oct 24 '22 07:10

WeMakeSoftware


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

like image 22
sag Avatar answered Oct 24 '22 09:10

sag