Search This Blog

Tuesday, June 30, 2020

Spring Boot Hibernate 5 com.zaxxer.hikari.pool. active Connection is not Release

1. maxpoolsize = 100
2. idle time out = reduced to 10 seconds
3. save method in repo/services classes should close in entityManager
close in finally block {}
4. also told spring to use hibernate5.SpringContext in application.properties

 
4th application.properties

spring.datasource.hikari.leak-detection-threshold=10000
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext

1 & 2 in HikariPool Datasource settings

url=xxx
username=xx
password=xx
driverClassName=com.mysql.jdbc.Driver
connectionTimeout=30000
maxPoolSize=100
idleTimeout=10000
minIdle=10
poolName=xxxdb-connection-pool


3rd - EntityManager Connection close
 EntityManager entityManager = entityManagerFactory.createEntityManager ();
        try
        {
            if ( entityManager != null )
            {
                entityManager.getTransaction ().begin ();
                entityManager.merge ( xxx );
                entityManager.getTransaction ().commit ();
            }
        }
        catch ( Exception e )
        {
            System.out.println ( e.getMessage () );
        }
        finally
        {
            if ( entityManager != null )
            {
                entityManager.close ();
            }
        }






No comments:

Hit Counter


View My Stats