2

I have come across some datasource properties for Spring Boot, that are specified in the application.properties. I am having a hard time understanding the purpose of the datasource properties. Also, I am not able to find the explanation of these properties here for datasource - https://docs.spring.io/spring-boot/docs/1.1.2.RELEASE/reference/html/common-application-properties.html and I am using Spring Boot version 1.

spring.datasource.test-while-idle=true
spring.datasource.initial-size=10
spring.datasource.min-idle=10
spring.datasource.time-between-eviction-runs-millis=300000 
spring.datasource.validation-query=SELECT 1 from DUAL
spring.datasource.test-on-borrow=true
spring.datasource.test-on-connect=true
spring.datasource.validation-interval=300000

The properties are validation-interval and time-between-eviction-runs-millis. What is the difference between them? The latter runs to evict the dead connections. But what about validation-interval?

Difference between test-on-borrow and test-on-connect?

I can't seem to find the right place to see their documentation or their purpose, or I am looking at the wrong place.

Please advise.

IceMan
  • 123
  • 2
  • 11
  • 1
    Please refer to this https://stackoverflow.com/questions/30451470/connection-to-db-dies-after-424-in-spring-boot-jpa-hibernate you can get some useful information – Rajendra Gupta Jul 26 '19 at 15:59
  • Thank you for the link. But its the same thing over there as well - no explanation as to what the two properties are. – IceMan Jul 26 '19 at 16:14

1 Answers1

1

Following explanation is based on my experience, for your reference.

spring.datasource.time-between-eviction-runs-millis means the time interval to recycle idle connection. It is usually used with spring.datasource.test-while-idle.

spring.datasource.min-evictable-idle-time-millis means the effective time of idle connection in connection pool.

spring.datasource.test-on-borrow means whether testing the connection while borrowing the connection from connection pool. And it may have some impact on the performance.

spring.datasource.test-on-connect means whether testing the connection while creating the connection.

Rajendra Gupta
  • 381
  • 1
  • 16
LHCHIN
  • 3,679
  • 2
  • 16
  • 34