pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feed"nested transaction" - encosing statement gets closed when the enclosed statement is closed
3+ messages / 2 participants
[nested] [flat]
* "nested transaction" - encosing statement gets closed when the enclosed statement is closed
@ 2007-01-15 13:11 Havard Tveite <havard.tveite@umb.no>
2007-01-15 17:30 ` Re: "nested transaction" - encosing statement gets closed Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 3+ messages in thread
From: Havard Tveite @ 2007-01-15 13:11 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: "nested transaction" - encosing statement gets closed
2007-01-15 13:11 "nested transaction" - encosing statement gets closed when the enclosed statement is closed Havard Tveite <havard.tveite@umb.no>
@ 2007-01-15 17:30 ` Kris Jurka <books@ejurka.com>
2007-01-16 08:16 ` Re: "nested transaction" - encosing statement gets closed Havard Tveite <havard.tveite@umb.no>
0 siblings, 1 reply; 3+ messages in thread
From: Kris Jurka @ 2007-01-15 17:30 UTC (permalink / raw)
To: Havard Tveite <havard.tveite@umb.no>; +Cc: pgsql-jdbc
On Mon, 15 Jan 2007, Havard Tveite wrote:
> 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.
>
Are you sure it's complaining that stmt is closed. This coding clearly
looks like the problem will be with stmtchk as you close it in the loop,
but then continue using it.
> Statement stmtchk = conn.createStatement();
> while (rs.next()) {
> ResultSet rsch = stmtchk.executeQuery(checkquery);
> stmtchk.close(); // leads to the closing of stmt!!!
> }
>
Kris Jurka
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: "nested transaction" - encosing statement gets closed
2007-01-15 13:11 "nested transaction" - encosing statement gets closed when the enclosed statement is closed Havard Tveite <havard.tveite@umb.no>
2007-01-15 17:30 ` Re: "nested transaction" - encosing statement gets closed Kris Jurka <books@ejurka.com>
@ 2007-01-16 08:16 ` Havard Tveite <havard.tveite@umb.no>
0 siblings, 0 replies; 3+ messages in thread
From: Havard Tveite @ 2007-01-16 08:16 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
Kris Jurka wrote:
> On Mon, 15 Jan 2007, Havard Tveite wrote:
>
>> 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.
>>
>
> Are you sure it's complaining that stmt is closed. This coding clearly
> looks like the problem will be with stmtchk as you close it in the loop,
> but then continue using it.
You are right. I was so hung up in that it worked for
7.4.1 that I did not check things properly. Sorry!
Thank you for the help!
--
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2007-01-16 08:16 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-01-15 13:11 "nested transaction" - encosing statement gets closed when the enclosed statement is closed Havard Tveite <havard.tveite@umb.no>
2007-01-15 17:30 ` Re: "nested transaction" - encosing statement gets closed Kris Jurka <books@ejurka.com>
2007-01-16 08:16 ` Re: "nested transaction" - encosing statement gets closed Havard Tveite <havard.tveite@umb.no>
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