Its worth noting that the JDBC's behavior when you switch back to autocommit is to immediately commit the open transaction.
Personally, I think committing immediately or erroring are unsurprising behaviors. The current behavior is surprising and obviously wrong. Rolling back without an error would be very surprising (no other database API I know of does that) and would take forever to debug issues around the behavior. And committing after the next statement is definitely the most surprising behavior suggested. IMHO, I think committing immediately and erroring are both valid. I think I'd prefer the error in principle, and per the law of bad code I'm sure, although no one has ever intended to use this behavior, there is probably some code out there that is relying on this behavior for "correctness". I think a hard failure and making the dev add an explicit commit is least likely to cause people serious issues. As for the other options, consider me opposed. - Matt K.