pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedOpen connections
10+ messages / 6 participants
[nested] [flat]
* Open connections
@ 2004-12-28 11:34 Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 13:09 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
2004-12-28 15:48 ` Re: Open connections Scott Marlowe <smarlowe@g2switchworks.com>
0 siblings, 2 replies; 10+ messages in thread
From: Nico @ 2004-12-28 11:34 UTC (permalink / raw)
To: pgsql-jdbc
I would like to know how many connections are open at a certain time from a
servlet, so I can anticipate connection errors. How do I do that?
Nico.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Open connections
2004-12-28 11:34 Open connections Nico <nicohmail-postgresql@yahoo.com>
@ 2004-12-28 13:09 ` Dave Cramer <pg@fastcrypt.com>
2004-12-28 13:33 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
1 sibling, 1 reply; 10+ messages in thread
From: Dave Cramer @ 2004-12-28 13:09 UTC (permalink / raw)
To: Nico <nicohmail-postgresql@yahoo.com>; +Cc: pgsql-jdbc
Nico,
this is somewhat problematic, the only way to do this is to use the unix
tool ps to determine the number of processes.
A much better way to do this is to use a robust connection pool like
dbcp from apache, which will manage your connections for you.
Dave
Nico wrote:
>I would like to know how many connections are open at a certain time from a
>servlet, so I can anticipate connection errors. How do I do that?
>
>Nico.
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
>
>
>
--
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Open connections
2004-12-28 11:34 Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 13:09 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
@ 2004-12-28 13:33 ` Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 14:23 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
0 siblings, 1 reply; 10+ messages in thread
From: Nico @ 2004-12-28 13:33 UTC (permalink / raw)
To: pgsql-jdbc
I forgot to mention one thing: I have no control over the server it's
running on. I only have permission for my account. It is imperative that I
can have 4 open connections with my database, since my servlet generates a
framesetpage where each frame of the three frames is that same servlet with
other parameters to connect to the same database. Most of the time it's not
a problem, but when I get 3 or more visitors at the same time, my
connections start to make trouble. Here is my website:
http://www.haegenssites.com/servlet/menus.DBMenuShow?dbname=haegens_vva&menuid=311
"Dave Cramer" <pg@fastcrypt.com> schreef in bericht
news:41D15B20.5000409@fastcrypt.com...
> Nico,
>
> this is somewhat problematic, the only way to do this is to use the unix
> tool ps to determine the number of processes.
>
> A much better way to do this is to use a robust connection pool like dbcp
> from apache, which will manage your connections for you.
>
> Dave
>
> Nico wrote:
>
>>I would like to know how many connections are open at a certain time from
>>a servlet, so I can anticipate connection errors. How do I do that?
>>
>>Nico.
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 3: if posting/reading through Usenet, please send an appropriate
>> subscribe-nomail command to majordomo@postgresql.org so that your
>> message can get through to the mailing list cleanly
>>
>>
>>
>
> --
> Dave Cramer
> http://www.postgresintl.com
> 519 939 0336
> ICQ#14675561
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Open connections
2004-12-28 11:34 Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 13:09 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
2004-12-28 13:33 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
@ 2004-12-28 14:23 ` Dave Cramer <pg@fastcrypt.com>
2004-12-28 23:35 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
0 siblings, 1 reply; 10+ messages in thread
From: Dave Cramer @ 2004-12-28 14:23 UTC (permalink / raw)
To: Nico <nicohmail-postgresql@yahoo.com>; +Cc: pgsql-jdbc
Nico,
I would still share the connections using a pooling mechanism of some
kind. If every visitor is going to require 3 connections to the
database, you can never scale past a certain point anyway.
Most of the time the connection is only required for a short period of
time. ie request comes in, get the connection, get the result set, read
the result set into beans, or objects, return connection and then display.
This can be done with each frame/servlet
Dave
Nico wrote:
>I forgot to mention one thing: I have no control over the server it's
>running on. I only have permission for my account. It is imperative that I
>can have 4 open connections with my database, since my servlet generates a
>framesetpage where each frame of the three frames is that same servlet with
>other parameters to connect to the same database. Most of the time it's not
>a problem, but when I get 3 or more visitors at the same time, my
>connections start to make trouble. Here is my website:
>http://www.haegenssites.com/servlet/menus.DBMenuShow?dbname=haegens_vva&menuid=311
>
>"Dave Cramer" <pg@fastcrypt.com> schreef in bericht
>news:41D15B20.5000409@fastcrypt.com...
>
>
>>Nico,
>>
>>this is somewhat problematic, the only way to do this is to use the unix
>>tool ps to determine the number of processes.
>>
>>A much better way to do this is to use a robust connection pool like dbcp
>>from apache, which will manage your connections for you.
>>
>>Dave
>>
>>Nico wrote:
>>
>>
>>
>>>I would like to know how many connections are open at a certain time from
>>>a servlet, so I can anticipate connection errors. How do I do that?
>>>
>>>Nico.
>>>
>>>
>>>---------------------------(end of broadcast)---------------------------
>>>TIP 3: if posting/reading through Usenet, please send an appropriate
>>> subscribe-nomail command to majordomo@postgresql.org so that your
>>> message can get through to the mailing list cleanly
>>>
>>>
>>>
>>>
>>>
>>--
>>Dave Cramer
>>http://www.postgresintl.com
>>519 939 0336
>>ICQ#14675561
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 6: Have you searched our list archives?
>>
>> http://archives.postgresql.org
>>
>>
>>
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>
>
>
--
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Open connections
2004-12-28 11:34 Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 13:09 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
2004-12-28 13:33 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 14:23 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
@ 2004-12-28 23:35 ` Nico <nicohmail-postgresql@yahoo.com>
2004-12-29 04:46 ` Re: Open connections Rupa Schomaker <pgsql-jdbc@lists.rupa.com>
0 siblings, 1 reply; 10+ messages in thread
From: Nico @ 2004-12-28 23:35 UTC (permalink / raw)
To: pgsql-jdbc
That's where the next problem lies: I don't know anything about pooling mechanisms. Could you please give me a good place to get started? Or some code how to do so?
Thanks.
"Dave Cramer" <pg@fastcrypt.com> schreef in bericht news:41D16C5E.8010800@fastcrypt.com...
Nico,
I would still share the connections using a pooling mechanism of some kind. If every visitor is going to require 3 connections to the database, you can never scale past a certain point anyway.
Most of the time the connection is only required for a short period of time. ie request comes in, get the connection, get the result set, read the result set into beans, or objects, return connection and then display.
This can be done with each frame/servlet
Dave
Nico wrote:
I forgot to mention one thing: I have no control over the server it's
running on. I only have permission for my account. It is imperative that I
can have 4 open connections with my database, since my servlet generates a
framesetpage where each frame of the three frames is that same servlet with
other parameters to connect to the same database. Most of the time it's not
a problem, but when I get 3 or more visitors at the same time, my
connections start to make trouble. Here is my website:
http://www.haegenssites.com/servlet/menus.DBMenuShow?dbname=haegens_vva&menuid=311
"Dave Cramer" <pg@fastcrypt.com> schreef in bericht
news:41D15B20.5000409@fastcrypt.com...
Nico,
this is somewhat problematic, the only way to do this is to use the unix
tool ps to determine the number of processes.
A much better way to do this is to use a robust connection pool like dbcp
from apache, which will manage your connections for you.
Dave
Nico wrote:
I would like to know how many connections are open at a certain time from
a servlet, so I can anticipate connection errors. How do I do that?
Nico.
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
--
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
http://archives.postgresql.org
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
--
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Open connections
2004-12-28 11:34 Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 13:09 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
2004-12-28 13:33 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 14:23 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
2004-12-28 23:35 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
@ 2004-12-29 04:46 ` Rupa Schomaker <pgsql-jdbc@lists.rupa.com>
2004-12-31 16:08 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
0 siblings, 1 reply; 10+ messages in thread
From: Rupa Schomaker @ 2004-12-29 04:46 UTC (permalink / raw)
To: pgsql-jdbc
On 12/28/2004 3:35 PM, Nico wrote:
> That's where the next problem lies: I don't know anything about pooling
> mechanisms. Could you please give me a good place to get started? Or
> some code how to do so?
> Thanks.
The internet is a wonderful thing. I think someone already pointed out
dbcp.
First, what web container are you using? Nearly all come with a
connection pooling implementation. Tomcat is bundled with dbcp.
Second, if you can't figure out the first, then just use dbcp:
http://jakarta.apache.org/commons/dbcp/
[snip]
> --
> Dave Cramer
> http://www.postgresintl.com
> 519 939 0336
> ICQ#14675561
--
-Rupa
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Open connections
2004-12-28 11:34 Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 13:09 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
2004-12-28 13:33 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 14:23 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
2004-12-28 23:35 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-29 04:46 ` Re: Open connections Rupa Schomaker <pgsql-jdbc@lists.rupa.com>
@ 2004-12-31 16:08 ` Nico <nicohmail-postgresql@yahoo.com>
2004-12-31 17:40 ` Re: Open connections Rupa Schomaker (lists) <pgsql-jdbc@lists.rupa.com>
0 siblings, 1 reply; 10+ messages in thread
From: Nico @ 2004-12-31 16:08 UTC (permalink / raw)
To: pgsql-jdbc
Resin 3.0.8. Don't forget: I do not have permission to the resin
configuration files, only to my application files.
Nico.
"Rupa Schomaker" <pgsql-jdbc@lists.rupa.com> schreef in bericht
news:41D236C0.5090705@lists.rupa.com...
> On 12/28/2004 3:35 PM, Nico wrote:
>> That's where the next problem lies: I don't know anything about pooling
>> mechanisms. Could you please give me a good place to get started? Or
>> some code how to do so?
>> Thanks.
>
> The internet is a wonderful thing. I think someone already pointed out
> dbcp.
>
> First, what web container are you using? Nearly all come with a
> connection pooling implementation. Tomcat is bundled with dbcp.
>
> Second, if you can't figure out the first, then just use dbcp:
>
> http://jakarta.apache.org/commons/dbcp/
>
> [snip]
>
>> --
>> Dave Cramer
>> http://www.postgresintl.com
>> 519 939 0336
>> ICQ#14675561
>
>
> --
> -Rupa
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Open connections
2004-12-28 11:34 Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 13:09 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
2004-12-28 13:33 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 14:23 ` Re: Open connections Dave Cramer <pg@fastcrypt.com>
2004-12-28 23:35 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-29 04:46 ` Re: Open connections Rupa Schomaker <pgsql-jdbc@lists.rupa.com>
2004-12-31 16:08 ` Re: Open connections Nico <nicohmail-postgresql@yahoo.com>
@ 2004-12-31 17:40 ` Rupa Schomaker (lists) <pgsql-jdbc@lists.rupa.com>
0 siblings, 0 replies; 10+ messages in thread
From: Rupa Schomaker (lists) @ 2004-12-31 17:40 UTC (permalink / raw)
To: pgsql-jdbc
On 12/31/2004 8:08 AM, Nico wrote:
> Resin 3.0.8. Don't forget: I do not have permission to the resin
> configuration files, only to my application files.
> Nico.
Don't top post.
http://www.caucho.com/resin-3.0/features/overview.xtp#db
--
-Rupa
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Open connections
2004-12-28 11:34 Open connections Nico <nicohmail-postgresql@yahoo.com>
@ 2004-12-28 15:48 ` Scott Marlowe <smarlowe@g2switchworks.com>
2004-12-28 20:23 ` Re: Open connections Kris Jurka <books@ejurka.com>
1 sibling, 1 reply; 10+ messages in thread
From: Scott Marlowe @ 2004-12-28 15:48 UTC (permalink / raw)
To: Nico <nicohmail-postgresql@yahoo.com>; +Cc: pgsql-jdbc
On Tue, 2004-12-28 at 05:34, Nico wrote:
> I would like to know how many connections are open at a certain time from a
> servlet, so I can anticipate connection errors. How do I do that?
Assuming that stats_row_level = true is set in the postgresql.conf file,
you can find out with:
SELECT * from pg_stat_activity;
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Open connections
2004-12-28 11:34 Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 15:48 ` Re: Open connections Scott Marlowe <smarlowe@g2switchworks.com>
@ 2004-12-28 20:23 ` Kris Jurka <books@ejurka.com>
0 siblings, 0 replies; 10+ messages in thread
From: Kris Jurka @ 2004-12-28 20:23 UTC (permalink / raw)
To: Scott Marlowe <smarlowe@g2switchworks.com>; +Cc: Nico <nicohmail-postgresql@yahoo.com>; pgsql-jdbc
On Tue, 28 Dec 2004, Scott Marlowe wrote:
> Assuming that stats_row_level = true is set in the postgresql.conf file,
> you can find out with:
>
> SELECT * from pg_stat_activity;
>
pg_stat_activity does not require row level stats. To get the command
string in this view you need stats_command_string enabled, but again
that's not necessary to just see open connections.
This method doesn't seem like a real solution to the problem at hand
though. How are you going to determine if you are allowed to make a
connection to the database? By making a connection to the database and
querying this view? Note also that the pg_stat_activity view lags reality
by up to a half a second. Note also that the max_connections setting is
per cluster, not per database, so you cannot know or control what other
clients are going to do with other databases.
I would definitely consider a connection pool as others have
suggested and possibly moving away from frames entirely.
Kris Jurka
^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2004-12-31 17:40 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-12-28 11:34 Open connections Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 13:09 ` Dave Cramer <pg@fastcrypt.com>
2004-12-28 13:33 ` Nico <nicohmail-postgresql@yahoo.com>
2004-12-28 14:23 ` Dave Cramer <pg@fastcrypt.com>
2004-12-28 23:35 ` Nico <nicohmail-postgresql@yahoo.com>
2004-12-29 04:46 ` Rupa Schomaker <pgsql-jdbc@lists.rupa.com>
2004-12-31 16:08 ` Nico <nicohmail-postgresql@yahoo.com>
2004-12-31 17:40 ` Rupa Schomaker (lists) <pgsql-jdbc@lists.rupa.com>
2004-12-28 15:48 ` Scott Marlowe <smarlowe@g2switchworks.com>
2004-12-28 20:23 ` Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox