Thread: How can I to solute this problem?

How can I to solute this problem?

From
"LEON"
Date:
I use tomcat+linux_postgresql+jsp to develop system.
 
I start postgresql with 1024 processes.
FE:
postmaster -i -S -N 1024 -B 2048 -D /var/lib/pgsql/data
 
My jsp doesn't implement connection pool.It directly connects postgresql by jdbc.
 
After I run the Ui some times, the UI(jsp) would report "ieSorry,too many clientslg" .The exception is SQLException.
 
I must restart tomcat or postgresql I can continue to running my UI.
 
 
May this problem be soluted?
 
 
Best regards.
                          leon
                      2003-07-29

Re: How can I to solute this problem?

From
Paul Thomas
Date:
On 29/07/2003 07:18 LEON wrote:
> I use tomcat+linux_postgresql+jsp to develop system.
> 
> I start postgresql with 1024 processes.
> FE:
> postmaster -i -S -N 1024 -B 2048 -D /var/lib/pgsql/data
> 
> My jsp doesn't implement connection pool.It directly connects postgresql
> by jdbc.

IME, that is not a good way to do it. Use a connection pool.

> After I run the Ui some times, the UI(jsp) would report "ieSorry,too many
> clientslg" .The exception is SQLException.
> 
> I must restart tomcat or postgresql I can continue to running my UI.

My guess would be that you have a bug in your application which is not 
always closing the connection so eventually you exceed max_connections. 
You should always close the connection in a finally{} block so that is 
guaranteed that it will be closed regardless of any earlier exceptions 
which are thrown.

HTH

-- 
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller 
Business |
| Computer Consultants         | 
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+


Re: How can I to solute this problem?

From
Achilleus Mantzios
Date:
You may take a look at jboss connection pool
mechanism. (postgresql.xml).

Also a good way of ensuring that your app will
not leave open stale postgresql connections
is to initially configure your pool to only have a small
number of connections (e.g. 2,3).

If your J2EE components (e.g. jsps) are fast enough
you should start facing connection shortages
only after the load on your machine increases
significantly. (and then safely increase the maximum
number of connections in your configuration (both postgresql wise
and app server (conn pool) wise).


On Tue, 29 Jul 2003, Paul Thomas wrote:

> 
> On 29/07/2003 07:18 LEON wrote:
> > I use tomcat+linux_postgresql+jsp to develop system.
> > 
> > I start postgresql with 1024 processes.
> > FE:
> > postmaster -i -S -N 1024 -B 2048 -D /var/lib/pgsql/data
> > 
> > My jsp doesn't implement connection pool.It directly connects postgresql
> > by jdbc.
> 
> IME, that is not a good way to do it. Use a connection pool.
> 
> > After I run the Ui some times, the UI(jsp) would report "ieSorry,too many
> > clientslg" .The exception is SQLException.
> > 
> > I must restart tomcat or postgresql I can continue to running my UI.
> 
> My guess would be that you have a bug in your application which is not 
> always closing the connection so eventually you exceed max_connections. 
> You should always close the connection in a finally{} block so that is 
> guaranteed that it will be closed regardless of any earlier exceptions 
> which are thrown.
> 
> HTH
> 
> 

-- 
==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel:    +30-210-8981112
fax:    +30-210-8981877
email:  achill at matrix dot gatewaynet dot com       mantzios at softlab dot ece dot ntua dot gr



Re: How can I to solute this problem?

From
Paul Thomas
Date:
On 29/07/2003 17:09 Achilleus Mantzios wrote:
> 
> You may take a look at jboss connection pool
> mechanism. (postgresql.xml)

He doesn't mention JBoss, just Tomcat so I don't believe the 
postgresql.xml will help him much. He could use Tomcat's built-in 
connection pooling 
(http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html) 
but should note that there is an error in the web.xml fragment: 
<res-ref-name>jdbc/mydb</res-ref-name> should be 
<res-ref-name>jdbc/postgres</res-ref-name>. Leon, if you need more help 
please feel free to contact me off-list.

> 
> Also a good way of ensuring that your app will
> not leave open stale postgresql connections
> is to initially configure your pool to only have a small
> number of connections (e.g. 2,3).

Good advice for any form of connection pooling.

> 
> If your J2EE components (e.g. jsps) are fast enough
> you should start facing connection shortages
> only after the load on your machine increases
> significantly. (and then safely increase the maximum
> number of connections in your configuration (both postgresql wise
> and app server (conn pool) wise).
> 
> 
> On Tue, 29 Jul 2003, Paul Thomas wrote:
> 
> >
> > On 29/07/2003 07:18 LEON wrote:
> > > I use tomcat+linux_postgresql+jsp to develop system.
> > >
> > > I start postgresql with 1024 processes.
> > > FE:
> > > postmaster -i -S -N 1024 -B 2048 -D /var/lib/pgsql/data
> > >
> > > My jsp doesn't implement connection pool.It directly connects
> postgresql
> > > by jdbc.
> >
> > IME, that is not a good way to do it. Use a connection pool.
> >
> > > After I run the Ui some times, the UI(jsp) would report "ieSorry,too
> many
> > > clientslg" .The exception is SQLException.
> > >
> > > I must restart tomcat or postgresql I can continue to running my UI.
> >
> > My guess would be that you have a bug in your application which is not
> > always closing the connection so eventually you exceed max_connections.
> 
> > You should always close the connection in a finally{} block so that is
> > guaranteed that it will be closed regardless of any earlier exceptions
> > which are thrown.
> >
> > HTH
> >
> >
> 
> --
> ==================================================================
> Achilleus Mantzios
> S/W Engineer
> IT dept
> Dynacom Tankers Mngmt
> Nikis 4, Glyfada
> Athens 16610
> Greece
> tel:    +30-210-8981112
> fax:    +30-210-8981877
> email:  achill at matrix dot gatewaynet dot com
>         mantzios at softlab dot ece dot ntua dot gr
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
>                http://archives.postgresql.org
> 


Re: How can I to solute this problem?

From
"LEON"
Date:
Hi,Thank your help yesterday.

Now I met a new question.
When I continued to clicking UI(jsp) some time, I will get a error in page.It is "Http 404" and Exception is
"NullPoinerExcaption".

I checked the log of tomcat. It recorded a message"connected database failed. The user perporty is missing. It is
mandoatory".

netstat | grep postgres |wc -l
The connection number is 278

lsof -i :5432 | wc -l
60

How can I solute this problem?
Is there bug in postgresql's jdbc?

Could you give me help?

Best regards                                         leon                             2003-07-30

----- Original Message ----- 
From: "Paul Thomas" <paul@tmsl.demon.co.uk>
To: "Achilleus Mantzios" <achill@matrix.gatewaynet.com>
Cc: "LEON" <ldai@accunettech.com>; "pgsql-sql @ postgresql . org" <pgsql-sql@postgresql.org>
Sent: Tuesday, July 29, 2003 8:37 PM
Subject: Re: [SQL] How can I to solute this problem?


> On 29/07/2003 17:09 Achilleus Mantzios wrote:
> > 
> > You may take a look at jboss connection pool
> > mechanism. (postgresql.xml)
> 
> He doesn't mention JBoss, just Tomcat so I don't believe the 
> postgresql.xml will help him much. He could use Tomcat's built-in 
> connection pooling 
> (http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html) 
> but should note that there is an error in the web.xml fragment: 
> <res-ref-name>jdbc/mydb</res-ref-name> should be 
> <res-ref-name>jdbc/postgres</res-ref-name>. Leon, if you need more help 
> please feel free to contact me off-list.
> 
> > 
> > Also a good way of ensuring that your app will
> > not leave open stale postgresql connections
> > is to initially configure your pool to only have a small
> > number of connections (e.g. 2,3).
> 
> Good advice for any form of connection pooling.
> 
> > 
> > If your J2EE components (e.g. jsps) are fast enough
> > you should start facing connection shortages
> > only after the load on your machine increases
> > significantly. (and then safely increase the maximum
> > number of connections in your configuration (both postgresql wise
> > and app server (conn pool) wise).
> > 
> > 
> > On Tue, 29 Jul 2003, Paul Thomas wrote:
> > 
> > >
> > > On 29/07/2003 07:18 LEON wrote:
> > > > I use tomcat+linux_postgresql+jsp to develop system.
> > > >
> > > > I start postgresql with 1024 processes.
> > > > FE:
> > > > postmaster -i -S -N 1024 -B 2048 -D /var/lib/pgsql/data
> > > >
> > > > My jsp doesn't implement connection pool.It directly connects
> > postgresql
> > > > by jdbc.
> > >
> > > IME, that is not a good way to do it. Use a connection pool.
> > >
> > > > After I run the Ui some times, the UI(jsp) would report "ieSorry,too
> > many
> > > > clientslg" .The exception is SQLException.
> > > >
> > > > I must restart tomcat or postgresql I can continue to running my UI.
> > >
> > > My guess would be that you have a bug in your application which is not
> > > always closing the connection so eventually you exceed max_connections.
> > 
> > > You should always close the connection in a finally{} block so that is
> > > guaranteed that it will be closed regardless of any earlier exceptions
> > > which are thrown.
> > >
> > > HTH
> > >
> > >
> > 
> > --
> > ==================================================================
> > Achilleus Mantzios
> > S/W Engineer
> > IT dept
> > Dynacom Tankers Mngmt
> > Nikis 4, Glyfada
> > Athens 16610
> > Greece
> > tel:    +30-210-8981112
> > fax:    +30-210-8981877
> > email:  achill at matrix dot gatewaynet dot com
> >         mantzios at softlab dot ece dot ntua dot gr
> > 
> > 
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> > 
> >                http://archives.postgresql.org
> > 
> 

Re: How can I to solute this problem?

From
Paul Thomas
Date:
On 30/07/2003 10:43 LEON wrote:
> Hi,Thank your help yesterday.
> 
> Now I met a new question.
> When I continued to clicking UI(jsp) some time, I will get a error in
> page.It is "Http 404" and Exception is "NullPoinerExcaption".
> 
> I checked the log of tomcat. It recorded a message"connected database
> failed. The user perporty is missing. It is mandoatory".
> 
> netstat | grep postgres |wc -l
> The connection number is 278
> 
> lsof -i :5432 | wc -l
> 60
> 
> How can I solute this problem?
> Is there bug in postgresql's jdbc?
> 
> Could you give me help?

You must supply the user name in your DriverManager.getConnection(url, 
user, password).

HTH

-- 
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller 
Business |
| Computer Consultants         | 
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+


Re: How can I to solute this problem?

From
Achilleus Mantzios
Date:
You may take a look at jboss connection pool
mechanism. (postgresql.xml).

Also a good way of ensuring that your app will
not leave open stale postgresql connections
is to initially configure your pool to only have a small
number of connections (e.g. 2,3).

If your J2EE components (e.g. jsps) are fast enough
you should start facing connection shortages
only after the load on your machine increases
significantly. (and then safely increase the maximum
number of connections in your configuration (both postgresql wise
and app server (conn pool) wise).

On Tue, 29 Jul 2003, Paul Thomas wrote:

> 
> On 29/07/2003 07:18 LEON wrote:
> > I use tomcat+linux_postgresql+jsp to develop system.
> > 
> > I start postgresql with 1024 processes.
> > FE:
> > postmaster -i -S -N 1024 -B 2048 -D /var/lib/pgsql/data
> > 
> > My jsp doesn't implement connection pool.It directly connects postgresql
> > by jdbc.
> 
> IME, that is not a good way to do it. Use a connection pool.
> 
> > After I run the Ui some times, the UI(jsp) would report "ieSorry,too many
> > clientslg" .The exception is SQLException.
> > 
> > I must restart tomcat or postgresql I can continue to running my UI.
> 
> My guess would be that you have a bug in your application which is not 
> always closing the connection so eventually you exceed max_connections. 
> You should always close the connection in a finally{} block so that is 
> guaranteed that it will be closed regardless of any earlier exceptions 
> which are thrown.
> 
> HTH
> 
> 

-- 
==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel:    +30-210-8981112
fax:    +30-210-8981877
email:  achill at matrix dot gatewaynet dot com       mantzios at softlab dot ece dot ntua dot gr