Received: from mx99.openu.ac.il (arbel.openu.ac.il [147.233.32.4]) by hub.org (8.9.3/8.9.3) with ESMTP id MAA27834 for ; Tue, 13 Jul 1999 12:00:53 -0400 (EDT) (envelope-from herouth@oumail.openu.ac.il) Received: from talmon.openu.ac.il (talmon.openu.ac.il [147.233.32.11]) by mx99.openu.ac.il (Postfix) with ESMTP for id 782F04B636; Tue, 13 Jul 1999 19:00:52 +0300 (IDT) Received: from [147.233.159.109] (mac-herouth.pc.openu.ac.il) by talmon.openu.ac.il (Netscape Messaging Server 3.54) with ESMTP id AAA2D3C; Tue, 13 Jul 1999 19:04:00 +0300 X-Sender: herouth@shaked.cc.openu.ac.il Message-Id: In-Reply-To: <378B5EC5.68E3C307@okstate.edu> References: <378A6008.7A27021D@okstate.edu> <378AD798.7E9E10AF@slip.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Tue, 13 Jul 1999 19:01:05 +0300 To: "PAUL J THOMPSON" From: Herouth Maoz Subject: Re: [ADMIN] Extra Postgres Processes Cc: pgsql-interfaces@postgresql.org I am redirecting this to the INTERFACES list, where it belongs, as it has nothing to do with Postgres administration. At 18:44 +0300 on 13/07/1999, PAUL J THOMPSON wrote: > Ok. I have a class called QuizData which maintains all database > connections. An instance of this class is created by a servlet each time > it runs the doGet() method. In the finalize method of the QuizData > class, I have something like: > > if (isOpen()) { > db.close; > } > > isOpen() returns the value of a instance variable of type boolean in the > object (QuizData) when the database is successfully opened. > > How does that sound? Anything else needed so far? Er, finalize method? It is called only when the object is about to be garbage collected. That is, only when the VM is short in memory. This is definitely not the way to go (I have a feeling you learned Java after learning C++. Finalize is rarely used in practice that I know). No, there are two ways to go about this. Either have a close() method in the QuizData which calls the above sentence, and remember to call this when you finish working with the QuizData, or have a timer thread that sets turns off the connection X minutes after its last usage. This should require a bit of design, though. Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma