0

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.

Krishnan V S
  • 1,124
  • 1
  • 13
  • 31
  • show your code, you might not close or open connections properly – Ori Marko Jul 26 '21 at 06:22
  • We are using JpaRepository, so no explicit opening or closing connection. The object directly connects to the table and fetches the data based on input params. Sharing that class code. – Krishnan V S Jul 26 '21 at 06:27
  • See if answers helps https://stackoverflow.com/questions/50014066/spring-boot-2-hikari-connection-pool-optimization/50114901#50114901 https://stackoverflow.com/questions/51136693/how-to-check-hikaricp-connection-pooling-is-working-or-not-in-java/52075009#52075009 – Ori Marko Jul 26 '21 at 06:33
  • Thanks. They do not mention about connection release but will try out those configurations – Krishnan V S Jul 26 '21 at 06:38

0 Answers0