I am using a reusable EntityManager design, similar to
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
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.