X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 88FE09DCC71 for ; Thu, 16 Feb 2006 10:14:07 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04260-02 for ; Thu, 16 Feb 2006 10:14:10 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) by postgresql.org (Postfix) with ESMTP id CF05D9DCC4F for ; Thu, 16 Feb 2006 10:14:04 -0400 (AST) Received: from kingfisher.intern.logix-tt.com (Me829.m.pppool.de [89.49.232.41]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 434A9244080; Thu, 16 Feb 2006 15:14:13 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 4342C18189F88; Wed, 15 Feb 2006 14:23:22 +0100 (CET) Message-ID: <43F32B48.8080104@logix-tt.com> Date: Wed, 15 Feb 2006 14:23:20 +0100 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Carlos Correia Cc: pgsql-jdbc@postgresql.org Subject: Re: When to close a Statement References: <43F32694.1050005@m16e.com> In-Reply-To: <43F32694.1050005@m16e.com> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.122 required=5 tests=[AWL=0.122] X-Spam-Score: 0.122 X-Spam-Level: X-Archive-Number: 200602/122 X-Sequence-Number: 14719 Hi, Carlos, Carlos Correia wrote: > After having had some problems with JDBC statements, as I mentioned in a > previous post, due to different behaviours between versions 7.x and 8.x > in the way Postgres deals with statements, I would like to know what is > the proper way of dealing with this. > > I realized that the need to close the statement is implementaion > dependent, and now I'm a bit confused as I can't find anything in > Postgres docs about this issue... so the questions are: > > - must I close the statement after *every* executeXXX method call? No, only close it if you don't need it any more. But reusing a statement closes the ResultSet from the last query used with this statement. The same is for begin/abort/commit. > - should I also close the connection as well, or may I leave it open > during the application execution? Keep it open as long as possible (or use a connection pool), because reopening a connection is slow. HTH, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org