Skip site navigation (1) Skip section navigation (2)

Re: [INTERFACES] JDBC IOException: Broken pipe

From: Peter T Mount <peter(at)retep(dot)org(dot)uk>
To: Frank Morton <fmorton(at)mail(dot)base2inc(dot)com>
Cc: pgsql-interfaces MailingList <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: [INTERFACES] JDBC IOException: Broken pipe
Date: 1998-08-05 05:41:53
Message-ID: Pine.LNX.3.96.980805063432.13326J-100000@maidast.retep.org.uk (view raw or flat)
Thread:
Lists: pgsql-interfaces
On Tue, 4 Aug 1998, Frank Morton wrote:

> I'm new to the list, though I have been using postgresql for awhile.
> 
> My understanding is that the JDBC driver is not thread safe, so
> what I have been doing is opening a new connection to the database
> for each thread. In this application, generally 5 to 10 threads
> are running.
> 
> I am using Solaris 2.5.1 with postgresql 6.3.2.
> 
> My problem is that after running "awhile" (which I will call 24 hours,
> though I am not sure yet if that is long or short) even the most
> simple application will start getting java.io.IOException: Broken pipe
> exceptions, which I assume means that the database has disappeared.
> Is that right?

Yes, that is correct.

> I am looking for advice in general regarding how I am handling
> the threading situation and if anyone can shed any light on how
> to avoid "Broken pipe".

One method I've heared about is to create a pool of connections.

When a thread needs to use a connection, then it requests one from a pool
manager class, and returns it when it's done. This would allow you to keep
the number of open connections down, especially if your threads only
access the database once in a while.

The manager class would check each connection before handing it out, and
if it's dead (or if it's run out of free connections), it creates a new
one.

This is how some servelets are handling persistent connections.

-- 
Peter T Mount peter(at)retep(dot)org(dot)uk or petermount(at)earthling(dot)net
Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres


In response to

pgsql-interfaces by date

Next:From: Peter T MountDate: 1998-08-05 05:43:49
Subject: Re: [INTERFACES] JDBC:postgresql and Symantec Visual Cafe
Previous:From: Aleksey DemakovDate: 1998-08-05 03:57:55
Subject: Re: [INTERFACES] How translate KOI-8 to Win1251 whith PsqlODBC

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group