autocommit == false; close(); // what happens?
843854May 4 2005 — edited May 10 2005I'm currently writing a simple implementation of a DataSource which just wraps an exsiting Connection (Yeah, I know there are better ways for handling database connectivity - let's just say I'm forced to do so...).
I want to make sure that whenever I return the connection, autocommit is set to true, as defined by JDBC.
Now, suppose I have a previously used java.sql.Connection which autocommit value is set to false.
I wan't to set autocommit to true now, but this would commit data of a connection which, from a meta-point of view, is already closed. Obviously, I would execute a rollback at this point.
Okay, but maybe handling this autocommit stuff should be done when the connection is "closed", i.e. returned to my so-called pool. And here, I am not sure what to do. My point of view is to make a rollback also, but I'm not sure if this would be appropriate.
All applications I know just ask you what to do in such cases. But this is surely not the thing I can do here, and I don't know of any default behaviour for this.
So, does JDBC say anything about this scenario? I did not find anything related.
The commons DBCP (http://jakarta.apache.org/commons/dbcp/) seems to ignore this issue.
Thanks in advance,
Sebastian