Hi Rodney/John,

>I'm not sure what is being proposed here, so if this is wrong let me
>know.  But code that is something like the following is not a good idea:
>
>Connection con = pool.getConnection();
>...do something...
>con.close();
>...
>if (!con.isClosed())
>  con.close();

As I said earlier, what I'm doing here is something like this

void func() {
    Connection conn = null;
    try {
        for (i = 0; i < NUM_DATABASES; ++i) {
            conn = DriverManager.getConnection(driverURL);
            // do something with connection .......
            conn.close();
        }
    } // end try
    catch() {
        //.
    }
    finally {
        // Try to be sure to clean the resources
        if (!conn.isClosed()) {
            conn.close();
        } // end if
    } // end finally
} //end func

I'm new to Jakarta as well as commons. Do you know how to 
go about getting a fix to this ? Which are the files that need
to be fixed ? I welcome your suggestions.

Thank you very much,

Best Regards,
ANJAN. B


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of John McNally
Sent: Tuesday, April 02, 2002 3:32 PM
To: Jakarta Commons Developers List
Subject: Re: [DBCP] : DelegatingConnection/PoolableConnection Bug ?


I'm not sure what is being proposed here, so if this is wrong let me
know.  But code that is something like the following is not a good idea:

Connection con = pool.getConnection();
...do something...
con.close();
...
if (!con.isClosed())
  con.close();

I think dbcp hands out the same Connection objects over and over again. 
Once the first close() is called, another thread may access the
connection, so that now isClosed would return false and the connection
is closed again while another thread is using it.

The jdbc2 spec says that a pool should always return a new Connection
object from the getConnection method, and if dbcp does this, maybe this
coding style has some merit, though I am kind of confused as to its
purpose.

fyi, jdbc2pool in the sandbox does hand out new logical Connections for
each call to getConnection.
And once isClosed() returns true, it will always return true.

john mcnally

Anjan wrote:
> 
> Hi Rodney!,
> 
>         Thank you for acknowledging that this could need a fix.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to