Solved

FATAL: sorry, too many clients already

Posted on 2010-08-16
4
1,493 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
  • 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

809 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