pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Havard Tveite <havard.tveite@umb.no>
To: pgsql-jdbc@postgresql.org
Subject: "nested transaction" - encosing statement gets closed when the enclosed statement is closed
Date: Mon, 15 Jan 2007 14:11:12 +0100
Message-ID: <45AB7D70.5050702@umb.no> (raw)

I have experienced problems using the JDBC type 2 and type 3
drivers for 8.1 (postgresql-8.1-408.jdbc3.jar,
postgresql-8.1-408.jdbc2.jar) against PostgreSQL 8.1.5.

I am running through the ResultSet of a select query that
involves a join, and for each result I do a lookup on one
of the tables in the join.

   Statement stmt = conn.createStatement();
   Statement stmtchk = conn.createStatement();
     ....
   ResultSet rs = stmt.executeQuery(searchquery);
     ....
   while (rs.next()) {
       .....

For the lookup, I do

     ResultSet rsch = stmtchk.executeQuery(checkquery);
     while (rsch.next()) {
       maxrefid = rsch.getInt("max");
     }
     rsch.close();
     stmtchk.close(); // leads to the closing of stmt!!!

     ...
   } // while


For some reason, the ResultSet that I am looping through is
closed by the lookup, and I receive the following exception:
"SQL Exception (working on resultset)! (selecttempmaps):
  org.postgresql.util.PSQLException: This statement has been closed."

In PostgreSQL 7.4.1 I did not experience this behaviour.

As you can see, I am using a new statement for the lookup.
I have also tried to create a new connection for the lookup,
but the problem persists.

If I comment out stmtchk.close(), the application runs as
it did in 7.4.1.


Is this expected behaviour?


-- 
Håvard Tveite
Department of Mathematical Sciences and Technology, UMB
Drøbakveien 14, POBox 5003, N-1432 Ås, NORWAY
Phone: +47 64965483 Fax: +47 64965401 http://www.umb.no/imt



view thread (3+ messages)  latest in thread

Message-ID: <45AB7D70.5050702@umb.no>
Permalink:  ../45AB7D70.5050702@umb.no/
Also on:    postgresql.org/message-id/45AB7D70.5050702@umb.no

 · 

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: havard.tveite@umb.no
  Subject: Re: "nested transaction" - encosing statement gets closed when the enclosed statement is closed
  In-Reply-To: <45AB7D70.5050702@umb.no>
  References: <45AB7D70.5050702@umb.no>

* 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