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

Re: Getting "This ResultSet is closed" exceptions

From: Jan de Visser <jdevisser(at)digitalfairway(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Cc: "Paul Tomblin" <ptomblin(at)gmail(dot)com>
Subject: Re: Getting "This ResultSet is closed" exceptions
Date: 2008-02-18 22:08:06
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
On Monday 18 February 2008 14:48:24 Paul Tomblin wrote:
> Forgive a possibly stupid question, but how would a class know whether
> there is a Connection for this thread already?  I use a simple static
> to hold the Connection, and so I get one for the whole program.

That sounds like a bad plan to me. You're going to interleave transactions 
etc. (You are using transactions, aren't you? :) Look into connection pools 
(apache has DBCP which is good), or otherwise 
use a threadlocal that keeps a connection per thread around.

> But 
> there is a lot of asynchronous stuff going on with GUI callbacks,
> external "messages" and RMI calls, etc.  Do I have to create and
> destroy a connection in every callback, or use some sort of thread
> pooling system?  A previous engineer on this project had one subsystem
> that was creating a new database connection every second, and then
> closing it a few milliseconds later - that seems like madness to me

Creative, but not very scalable :)


Jan de Visser                     jdevisser(at)digitalfairway(dot)com

                Baruk Khazad! Khazad ai-menu!

In response to


pgsql-jdbc by date

Next:From: Paul TomblinDate: 2008-02-18 23:07:59
Subject: Re: Getting "This ResultSet is closed" exceptions
Previous:From: Paul TomblinDate: 2008-02-18 19:48:24
Subject: Re: Getting "This ResultSet is closed" exceptions

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