How to customize the spring boot default properties of connection pool - spring-boot

I am using Spring boot + MySQL + Data JPA.
When I started my spring boot app, its taking initial pool size as 10.
I have tried to customize it using following property:
spring.datasource.dbcp2.initial-size=20
But its not working. How to fix this ?

If you don't configure your Connection Pool, Spring Boot will pick HikariCP at default. The connection pool for HikariCP can be configured as following:
spring.datasource.hikari.maximum-pool-size=5

Related

Do i need c3p0 for Springboot 2.x?

I am migrating a existing Spring application (non Spring boot) to Springboot 2.x. I see there is a c3p0.properties file with following configuration: com.mchange.v2.c3p0.management.ExcludeIdentityToken=true. What does this does exactly? Do I need this if I am using Springboot 2.x? Or do I need to setup something else configuration in my application.properties file?
Thank you for help.
Spring Boot 2.x use HikariCp as a default JDBC connection pool. It is faster then c3p0.
You should use Hikari.
You can read about it compared with c2p0:
Hikari vs other CPs
Spring Boot will autoconfig it to you, but you can customize it (for example in application.properties)
For the com.mchange.v2.c3p0.management.ExcludeIdentityToken visit the documentation page's Jmx configuration section
JMX configuration

Spring boot, spring data jpa application - how to check which connection pool being used?

How to check what is the connection pool being used by default. I am using Spring boot version 1.5.4.RELEASE
UPDATE : https://www.mkyong.com/spring-boot/spring-boot-how-to-know-which-connection-pool-is-used/
Spring Boot uses HikariCP as the default connection pool, due to its remarkable performance and enterprise-ready features.
Here’s how Spring Boot automatically configures a connection pool datasource:
Spring Boot will look for HikariCP on the classpath and use it by
default when present
If HikariCP is not found on the classpath, then Spring Boot will pick
up the Tomcat JDBC Connection Pool, if it’s available
If neither of these options is available, Spring Boot will choose
Apache Commons DBCP2, if that is available
Source: https://www.baeldung.com/spring-boot-tomcat-connection-pool

Avoid resetting HikariCP datasource connection pool on property change/refresh

I am using spring boot 2 with PCF config server to use centrallized config. My microservice is basic crud rest service. What I noticed is that whenever a property is being changed and http post is being made on "actuator/refresh" endpoint, spring boot 2 drops all connection including active ones and rebuilds the connection pool. How can I avoid this? I am also using spring-boot-starter amqp and cloud bus to notify all my service instance to refresh the properties so it is also happening for http post on "actuator/bus-refresh".
Also to clarify, I didnot change any property related to datasource config, instead I am changing application specific property, so why does spring boot refreshing datasource, I did not understood.

How do I setup connection pooling in spring boot for Elasticsearch

I have created a spring boot application that uses spring boot starter data elasticsearch to connect to elasticsearch. I want to configure this application to setup connection pooling. How do I configure the application.properties to support it?
Old answer. Since Boot 2.2, the reactive client doesn't have these options.
From the docs:
spring.data.elasticsearch.properties.*= # Additional properties used to configure the client.
Though it does appear that the default TransportClient does pool connections anyway.

Using jndi in spring with WAS?

I want to use Server Managed connection pool in my web application,Now i'm using JdbcTemplate to get the connection.How to get the datasource from the WebSphere and use in my application.
I googled but got confused with JndiTemplate and JdbcTemplate..
A good guide to Websphere + Spring can be found at Using Spring and Hibernate with WebSphere Application Server

Resources