Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

FATAL: sorry, too many clients already

Posted on 2010-08-16
4
Medium Priority
?
1,733 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 280 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 720 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

636 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