In our Spring boot application, we have set the following properties in application.properties
server.port=xxxx
server.servlet.context-path=/
#datasource
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://<IP:Port>/<DB Name>
spring.datasource.username=<username>
spring.datasource.password=<pwd>
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.connection.release_mode=after_statement
.....
//Interface using JpaRepository
@Repository
public interface UserlicensesRepo extends JpaRepository<Userlicenses, Integer> {
Optional<Userlicenses> findById(Integer us);
Optional<Userlicenses> findByUsernameAndUserToken(String user, String token);
}
.....
//Using the repo instance to make DB call
Optional<Userlicenses> ul=userlicensesRepo.findByUsernameAndUserToken(userName, userTokenEncrypted);
The application is functionally working well but over a period of 4-5 days it is creating a lot of orphan DB connections leading to memory leak. We tried setting the "release_mode", please check if we have missed anything or made a mistake in the above configuration. Appreciate your help.