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