Re: closing statements when connection is closed

From: "Iain" <iain(at)mst(dot)co(dot)jp>
To: <pg(at)fastcrypt(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: closing statements when connection is closed
Date: 2004-02-10 04:53:53
Message-ID: 009d01c3ef91$e1cbebc0$7201a8c0@mst1x5r347kymb
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

I'm no expert on this, but leaving statements open uses memory as I
understand it, so if you open new statements instead of re-using them then
you should close them.

In my case I just wrote a batch pupdate process that runs in about 30
minutes and then exits, so all statements will be closed and memory returned
at the time the process ends, but I close them anyway. If your app is
intended to run for long periods of time and you are concerned about memory
leakage, then you should probably close statements and connections every
time you finish with them.

Someone wrote that you should clear warnings regulary too, as they can
consume memory in long running apps that re-use statements. That makes sense
to me.

The problem I had with my app was deciding what to do when there was an
error. I tried putting calls to the close() method in the
catch(SQLException ) block but the compiler complains about it. If anyone
has any ideas on that I'd like to hear them.

regards
Iain
----- Original Message -----
From: "Dave Cramer" <pg(at)fastcrypt(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Sent: Tuesday, February 10, 2004 1:16 PM
Subject: [JDBC] closing statements when connection is closed

> It would appear from the documentation that we are supposed to clean up
> JDBC resources when Connecton.close is called, would this include
> statements. We currently don't track them or clean them up?
>
> Opinions ?
>
> --
> Dave Cramer
> 519 939 0336
> ICQ # 14675561
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Iain 2004-02-10 05:51:01 Re: closing statements when connection is closed
Previous Message Oliver Jowett 2004-02-10 04:33:07 Re: closing statements when connection is closed