bhomass
asked on
FATAL: sorry, too many clients already
I am using a reusable EntityManager design, similar to
http://blog.julianpaas.com/?p=65
according to this approach, the EntityManager is kept alive (does not call em.close), so it is reused within a thread.
after running my program for a while, I start to get
org.postgresql.util.PSQLEx ception: FATAL: sorry, too many clients already
I am wondering if this is due to the fact I don't call em.close, and some how, too many threads ended up using too many connections.
It is a big change if I add in em.close every where. I wonder if someone can give me a tip whether this is the area of suspect, or there is some other way I can resolve this out of connection error.
I am using c3p0 connection pooling with max_size set at 20.
http://blog.julianpaas.com/?p=65
according to this approach, the EntityManager is kept alive (does not call em.close), so it is reused within a thread.
after running my program for a while, I start to get
org.postgresql.util.PSQLEx
I am wondering if this is due to the fact I don't call em.close, and some how, too many threads ended up using too many connections.
It is a big change if I add in em.close every where. I wonder if someone can give me a tip whether this is the area of suspect, or there is some other way I can resolve this out of connection error.
I am using c3p0 connection pooling with max_size set at 20.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
can I ask if I call em.close(), does that guarantee to close the db connection?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you open it manually / not use it in EJB methods, you have to close it manually as well.