Re: [JDBC] Getting "This ResultSet is closed" exceptions
On 18-Feb-08, at 2:48 PM, Paul Tomblin wrote:
> On Feb 18, 2008 2:10 PM, Andres Olarte <olarte.andres@gmail.com> > wrote: >> You might go for using a single connection per thread. Works for me. > > 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. 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.
And it was/is madness. Yes you want pooling mechanism, and I don't
think a single connection for the whole program is a good thing.
Certainly if you have async callbacks it's very likely you are
stomping on statements.
Dave
> > > > -- > For my assured failures and derelictions I ask pardon beforehand of my > betters and my equals in my Calling here assembled, praying that in > the hour of my temptations, weakness and weariness, the memory of this > my Obligation and of the company before whom it was entered into, may > return to me to aid, comfort and restrain. > > ---------------------------(end of > broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match
---------------------------(end of broadcast)---------------------------
TIP 1: 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
Received on Mon Feb 18 18:32:03 2008
This archive was generated by hypermail 2.1.8
: Wed Jun 18 2008 - 23:44:46 EDT
|