From: Guillaume Cottenceau <gc@mnc.ch>
To: Clifton Zama <csz@jhb.ucs.co.za>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: java connection closing itself
Date: 12 Apr 2005 12:54:23 +0200
Message-ID: <87aco4b6zk.fsf@meuh.mnc.ch> (raw)
In-Reply-To: <200504131026.04762.csz@jhb.ucs.co.za>
References: <200504131026.04762.csz@jhb.ucs.co.za>
Clifton Zama <csz 'at' jhb.ucs.co.za> writes:
> Hi
>
> What would cause a connection to automatically close within a
> java program.It gets to a point where I have an inner loop that
> calls a recursive method that creates resultsets.But I am
> closing all my result sets, so I do not know why the connection
> simply closes itself.Please help.
There is a "bug" in which the DB driver tells you that the
connection is closed, although it isn't really closed, in
situations where the data is not available anymore.
Such a situation occurs when a ResultSet has been closed but you
are still trying to extract data from it. A ResultSet can be
closed by calling its close method, but also implicitely when the
Statement object that generated it is closed, re-executed, or is
used to retrieve the next result from a sequence of multiple
results.
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSet.html#close()
To make it short: if you're nesting multiple #executeQuery() on a
single Statement object, you're going to have this problem if
your loop goes down the nesting and does subsequent accesses to
the ResultSet.
--
Guillaume Cottenceau
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: gc@mnc.ch, csz@jhb.ucs.co.za
Subject: Re: java connection closing itself
In-Reply-To: <87aco4b6zk.fsf@meuh.mnc.ch>
References: <200504131026.04762.csz@jhb.ucs.co.za> <87aco4b6zk.fsf@meuh.mnc.ch>
* 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