Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

autocommit == false; close(); // what happens?

843854May 4 2005 — edited May 10 2005
I'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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 7 2005
Added on May 4 2005
7 comments
1,629 views