My spring boot application always show me this whitelabel error in the morning: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.Persi
You can fix this by setting the property wait_timeout = 31536000 in the DB Server. This is equivalent to one year. In case if you DB is running in the AWS environment, go to Parameters group-> create a new group -> set wait_timeout = 31536000 and assign the newly created parameters group to your RDS instance. If you want to fix this in the spring boot instance, you can fix by C3P0 settings only, but I haven't tried that.
You can also see this link It tells you to include the following lines in the application.properties file.
spring.datasource.testWhileIdle = true
spring.datasource.timeBetweenEvictionRunsMillis = 3600000
spring.datasource.validationQuery = SELECT 1
Check this answer: Spring Boot JPA - configuring auto reconnect
In short, you'll need:
spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1