| From: | Markus Schaber <schabi(at)logix-tt(dot)com> | 
|---|---|
| To: | Carlos Correia <carlos(at)m16e(dot)com> | 
| Cc: | pgsql-jdbc(at)postgresql(dot)org | 
| Subject: | Re: When to close a Statement | 
| Date: | 2006-02-15 13:23:20 | 
| Message-ID: | 43F32B48.8080104@logix-tt.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-jdbc | 
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Carlos Correia | 2006-02-15 13:41:12 | Re: When to close a Statement | 
| Previous Message | Carlos Correia | 2006-02-15 13:03:16 | When to close a Statement |