pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Markus Schaber <schabi@logix-tt.com>
To: Carlos Correia <carlos@m16e.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: When to close a Statement
Date: Wed, 15 Feb 2006 14:23:20 +0100
Message-ID: <43F32B48.8080104@logix-tt.com> (raw)
In-Reply-To: <43F32694.1050005@m16e.com>
References: <43F32694.1050005@m16e.com>

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



view thread (4+ messages)  latest in thread

Message-ID: <43F32B48.8080104@logix-tt.com>
Permalink:  ../43F32B48.8080104@logix-tt.com/
Also on:    postgresql.org/message-id/43F32B48.8080104@logix-tt.com

 · 

reply

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: schabi@logix-tt.com, carlos@m16e.com
  Subject: Re: When to close a Statement
  In-Reply-To: <43F32B48.8080104@logix-tt.com>
  References: <43F32694.1050005@m16e.com> <43F32B48.8080104@logix-tt.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