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"); |
|
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).