From: Jan de Visser <jdevisser@digitalfairway.com>
To: pgsql-jdbc@postgresql.org
Cc: Paul Tomblin <ptomblin@gmail.com>
Subject: Re: Getting "This ResultSet is closed" exceptions
Date: Mon, 18 Feb 2008 17:08:06 -0500
Message-ID: <200802181708.07111.jdevisser@digitalfairway.com> (raw)
In-Reply-To: <8efd35820802181148o3325551fj2f4f7de7baab39a1@mail.gmail.com>
References: <8efd35820802180619l352d9b0eta35788642a5fc4eb@mail.gmail.com>
<3fccaa690802181110j4b5d1429ta8ea641f4ebb160@mail.gmail.com>
<8efd35820802181148o3325551fj2f4f7de7baab39a1@mail.gmail.com>
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 http://commons.apache.org/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
--
--------------------------------------------------------------
Jan de Visser jdevisser@digitalfairway.com
Baruk Khazad! Khazad ai-menu!
--------------------------------------------------------------
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: jdevisser@digitalfairway.com, ptomblin@gmail.com
Subject: Re: Getting "This ResultSet is closed" exceptions
In-Reply-To: <200802181708.07111.jdevisser@digitalfairway.com>
References: <8efd35820802180619l352d9b0eta35788642a5fc4eb@mail.gmail.com> <3fccaa690802181110j4b5d1429ta8ea641f4ebb160@mail.gmail.com> <8efd35820802181148o3325551fj2f4f7de7baab39a1@mail.gmail.com> <200802181708.07111.jdevisser@digitalfairway.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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