I have a web service on Azure, with a spring boot application. This application uses JPA to communicate with a MySQL server.
Running this application on localhost has not given me any issues, but as soon as I published the code to the web service, problems started to arise.
My main problem right now is that whenever I am not using the application for around 5 minutes, the connection to MySQL is getting dropped and it throws an error whenever I try to access it again: com.mysql.cj.exceptions.ConnectionIsClosedException: No operations allowed after connection closed.
And it never opens another connection, which means I have to restart my app.
I have been looking online for a while now for a solution and have only found that I should try putting ?autoReconnect=true
in my connection string, which unfortunately did not fix this issue.
Hope anyone can help.
spring.datasource.testWhileIdle = true
spring.datasource.timeBetweenEvictionRunsMillis = 60000 spring.datasource.validationQuery = SELECT 1
I found this by digging up more about prod deployments , should work.:)