"nested transaction" - encosing statement gets closed when the enclosed statement is closed

From: Havard Tveite <havard(dot)tveite(at)umb(dot)no>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: "nested transaction" - encosing statement gets closed when the enclosed statement is closed
Date: 2007-01-15 13:11:12
Message-ID: 45AB7D70.5050702@umb.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jeanna Geier 2007-01-15 16:36:27 Problem Retrieving/Refresing Data From Database
Previous Message Dave Cramer 2007-01-15 12:24:31 Re: executeBatch() and operation after error