Hi.
I'm running into issues with statements - with some irregularity I'm
getting a problem of statements returned from Connection.prepareStatement()
are "dead". It looks like this:
PreparedStatement ps = c.prepareStatement(sql);
ps.getConnection().isClosed() -> returns true
c.isClosed() -> returns false
It seems to be pointing to the ManagedConnection cache problem, and most
likely is because ManagedConnection.associateConnection() doesn't flush the
statement cache. It really should, at least if it can see that the new
connection is different from the previous connection. I'm "lucky" that the
statements that I get from the cache are "closed" (because connection that
spawned the statement is closed), it would be far worse if I were
retrieving and executing statements that belong to a different underlying
connection, and were able to execute them.
For now, I'll just disable the prepared statement caching as a workaround
to this.