Skip site navigation (1) Skip section navigation (2)

Re: double Statement.close() (on AIX 5.1)

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Victor Sergienko <singalen(at)mail(dot)ru>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: double Statement.close() (on AIX 5.1)
Date: 2004-02-24 12:23:44
Message-ID: 1077625424.10206.2.camel@localhost.localdomain (view raw or flat)
Thread:
Lists: pgsql-jdbc
Victor,

You are absolutely correct this should not happen. You do however
realize that close on a PooledConnection returns it to the pool?

Dave
On Tue, 2004-02-24 at 05:07, Victor Sergienko wrote:
> Gentlemen,
> 
> I beg your pardon for incomplete problem description.
> 
> On AIX 5.1, IBM Java 1.3.1 I'm using pg74jdbc3.jar dated 24.12.03.
> We have a flaw in a legacy program: it calls Statement.close() inside
> try() and in finally{} - thus, two times.
> On doing that, I get:
> 
> java.sql.SQLException: Statement has been closed
>         at org.postgresql.jdbc2.optional.PooledConnectionImpl$StatementHandler.invoke(
> PooledConnectionImpl.java(Compiled Code))
>         at $Proxy1.close(Unknown Source)(Compiled Code)                         
>         at SomeUserClass.someMethod(Something.java:1345)
> 
> As JDK java.sql.Statement.close() documentation specifies, calling
> Statement.close() on already close()d statement should have no effect.
> It's the way Oracle and MS SQL drivers behave, but PG driver throws
> this exception.
> 
> A pity, I cannot reproduce this statement on my working desk on
> Windows XP + Sun Java 1.3.1_02. If I get the possibility to debug on
> AIX, I can report more precisely.
> 
> Looks like it's postgresql\jdbc2\optional\PooledConnectionImpl.java,
> lines ~365:
> 
>             // All the rest is from the Statement interface
>             if (st == null || con.isClosed())
>             {
>                 throw new SQLException("Statement has been closed");
>             }
>             if (method.getName().equals("close"))
>             {
>                 try {
>                     st.close();
>                 } finally {
>                     con = null;
>                     st = null;
>                     return null;
>                 }
>             }
> 
>   As for me, this should look like:
> 
>             // All the rest is from the Statement interface
>             if (method.getName().equals("close"))
>             {
>                 try {
>                     if (st != null && !con.isClosed()) st.close();
>                 } finally {
>                     con = null;
>                     st = null;
>                     return null;
>                 }
>             }
>             if (st == null || con.isClosed())
>             {
>                 throw new SQLException("Statement has been closed");
>             }
> 
>   My question is: is it a known bug, an intended feature, or an
> OS/JDK-specific bug that was not known before? What's wrong with my
> suggestion?
> 
> Thank you.
>         
-- 
Dave Cramer
519 939 0336
ICQ # 14675561


In response to

Responses

pgsql-jdbc by date

Next:From: Kris JurkaDate: 2004-02-24 13:22:22
Subject: Re: double Statement.close() (on AIX 5.1)
Previous:From: Victor SergienkoDate: 2004-02-24 10:07:56
Subject: double Statement.close() (on AIX 5.1)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group