I have a Spring Boot App where I have configurations as in the attached image. I am getting connection error, that no connection available.
Can anyone please help in this regard? Not able to find the clue to this issue.
In my app I am not making any connection manually. Only I am injecting using @PersistenceContext
annotation EntityManager
or using Spring Data JPA Repository
When injecting using @PersistenceContext
I am not closing EntityManager
manually. Should I do that?
Update
This is the error that is coming when try to use psql to connect to the db
psql: FATAL: sorry, too many clients already
SOME MORE THOUGHTS
Case 1: If i have a loop and in each loop there is a db select Or if I have a multiple threads and I have db queries in them then more connections will be opened for each query?
Case 2: But if i use @Transactional
on controller endpoints then same connection will be used for all in that method stack
Are the above two statements true? Can the first case result in connections not available error?