Modeling "PSQLException: FATAL: sorry, too many customers already"

I tried to understand maximum open sessions, and sessiion was open and closed behavior. I came across this that I am not able to fully understand.

I want to simulate "PSQLException: FATAL: sorry, too many clients already"in my code. I set max_connections to 10.

and tried to execute this code:

Session session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();
        session = HibernateUtil.getSessionFactory().openSession();

I was expecting an error here, on the 11th call, which I do not understand. When I run the sql command SELECT datname, numbackends FROM pg_stat_database where datname = 'XXX';, which I believe, the account of the open session will be displayed, I see that it is limited to 10.

Please explain the behavior.

+4
source share
1 answer

, ( β„–2): 1) postgresql . , 2) Hibernate JDBC , . , - , . , , , .

+1

All Articles