Solved

FATAL: sorry, too many clients already

Posted on 2010-08-16
4
1,535 Views
Last Modified: 2013-12-22
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.PSQLException: 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.
0
Comment
Question by:bhomass
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 10

Expert Comment

by:Hegemon
ID: 33454085
in J2EE environment Entity Manager will automatically close at the end of your EJB method.
If you open it manually / not use it in EJB methods, you have to close it manually as well.
0
 
LVL 10

Assisted Solution

by:gordon_vt02
gordon_vt02 earned 70 total points
ID: 33454496
Check your database configuration and make sure the maximum connections are set high enough to support your application.  Are there any other apps using the database at the same time?  If so, make sure the connection limit can support all of them.
0
 

Author Comment

by:bhomass
ID: 33456128
can I ask if I call em.close(), does that guarantee to close the db connection?
0
 
LVL 10

Accepted Solution

by:
Hegemon earned 180 total points
ID: 33456144
In a managed J2EE environment (EJB) this will produce an exception.
In a non-managed environment, which I suspect is what you have, yes, it will release the connection and return it to the pool.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet example 11 59
Crystal Reports Licensing Questions 4 64
Bot application - advice 3 63
JDBC performance 8 29
In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question