On 1/11/06, Daniel John Debrunner <[EMAIL PROTECTED]> wrote: > Deepa Remesh wrote: > > Should a JDBC driver close the statement objects associated with a > > connection when the connection's close() method is called? > > > > I saw this in JDBC 3.0 spec (Section 13.1.3 Closing Statement Objects) > > "All Statement objects will be closed when the connection that created > > them is closed." But I found different behaviour with Derby embedded > > and client driver. When using embedded driver, it does not close the > > associated statement objects when connection.close() is called. In > > client driver, the connection object maintains a list of all open > > statements and closes them when connection.close() is called. > > > > I'd appreciate if someone can explain this difference and which > > behaviour is correct. > > I think you are seeing different implementations, but the behaviour is > the same. The close of the connection in embedded implicitly closes the > Statement object. Once an embedded connection is closed, any call on a > Statement object will result in an exception indicating the object is > closed.
Yes, the end result is same. I cannot do anything with the embedded statement after it's connection has been closed. When I call any method on the statement, embedded driver checks the status of the statement's connection by calling Connection.isClosed() method and returns a "No current connection" exception if the connection has been closed. With the client driver, I get "Invalid operation: statement closed" exception. Thanks for the responses. Deepa
