[ 
http://issues.apache.org/jira/browse/DERBY-1095?page=comments#action_12370305 ] 

Daniel John Debrunner commented on DERBY-1095:
----------------------------------------------

Knut wrote:

> In the client driver, NetConnection maintains a WeakHashMap with all
> open statements. When the connection is marked as closed, it will call
> markClosed() on the open statements. I'm afraid I don't see why it's a
> bad idea to do the same in EmbedConnection. Could you please explain?

Two reasons:

    1) Statement resources are already closed correctly on a connection.close() 
so I don't know what purpose this additional code is meant to solve.

    2) Performance overhead due to storage and additional object creation and 
garbage collection is a concern. Maybe if it's only at the
     Statement level it's not too bad a concern, but there would have to be 
some additional logic to handle server-side JDBC. In the server-side case
      I don't think you want to set up the WeakHashMap, if you did the 
performance overhead would be a concern, because with server-side
       logic there is no way for the application to hang onto statements for 
multiple applications like a JDBC client program can. Also J2EE
       applications tend to be stateless and therefore incur Statement creation 
on each execution.

For ResultSet.isClosed() a simple way of implementing it would be:

  if (isClosed)
     return true;
 
   try {
         checkExecStatus();
          return false;
} catch (SQLException sqle)
{
     return isClosed;
}

A similar approach would work for Statement.isClosed.

> Closing an embedded connection does not seem to close associated 
> EmbedStatements
> --------------------------------------------------------------------------------
>
>          Key: DERBY-1095
>          URL: http://issues.apache.org/jira/browse/DERBY-1095
>      Project: Derby
>         Type: Bug
>   Components: JDBC
>     Versions: 10.2.0.0
>     Reporter: Kristian Waagan
>     Assignee: Daniel John Debrunner
>     Priority: Minor
>  Attachments: Derby1095Repro.java
>
> Closing an embedded connection (calling EmbedConnection.close()) does not 
> seem to close associated EmbedStatements. 
> The severity of the bug is not determined. The least severe case is that the 
> internal EmbedStatement variable 'active' is not updated accordingly, the 
> most severe case is that the the resources bound to EmbedStatement will not 
> be viable for garbage collection until the EmbedStatement itself is (if user 
> keeps references to it).
> If methods on the statement are called, Derby will correctly throw an 
> NoCurrentConnection exception, but the close() method is still never called 
> automatically.
> The problem also seem to extend down to ResultSet.isClosed(), but this is 
> probably due to the bug in EmbedStatement.
> Problem detected while fixing DERBY-953; implement Statement.isClosed().

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to