-
Notifications
You must be signed in to change notification settings - Fork 614
Return proper error when user tries to enable transactions #659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return proper error when user tries to enable transactions #659
Conversation
Transactions are not supported, so `setAutoCommit(false)` should fail, as it does not provide the isolation or rollback-ability requested by the caller. `commit()` and `rollback()` should fail in auto-commit mode (this is what PostgreSQL JDBC driver does).
|
| @Override | ||
| public void rollback() throws SQLException { | ||
|
|
||
| throw new SQLException("Cannot commit when auto-commit is enabled"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo. Should be rollback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, changed
|
Thanks @findepi. We probably need an option to make it acting like a full featured driver, so that it will work with more clients. |
1 similar comment
|
Thanks @findepi. We probably need an option to make it acting like a full featured driver, so that it will work with more clients. |
|
Implementing transactions is obviously a good thing to do, but it's not something one can do within the driver itself, without support on the server side: For example, consider doing a "simulation": With current implementation (as visible on master), I understand, however, that some applications may be reliant on this incorrect behavior (for example some JPA systems may be tempted to use transactions unconditionally). @zhicwu Is this what you're concerned about? |
|
Yes. And you're right that the behavior is incorrect. Having said that, it might be helpful by providing the option so that people can choose. It's still an immature thought but we may get back to this later. Anyway, thanks again for the pull request, I have no problem to merge it into next release, cheers! |
|
thanks for a quick merge! |
Transactions are not supported, so
setAutoCommit(false)should fail,as it does not provide the isolation or rollback-ability requested by
the caller.
commit()androllback()should fail in auto-commit mode (this iswhat PostgreSQL JDBC driver does).