是否可以在 Select
语句中使用 sqlMapClient.startTransaction();
和 sqlMapClient.commitTransaction();
?
我已经为 insert 、 update 和 select 语句提供了 start 和 commit 事务,但在某处出现错误。
MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:
All connection started and closed. and given for each start transactions. Nothing has added in catch block.
finally {
sqlMapClient.endTransaction();
}
我想没有必要对 select 语句使用 start/commit transaction。谁能澄清一下?
最佳答案
错误只是表明连接已经关闭,您可能错过了一些异常/错误。
要回答你的问题,select当然可以在一个事务中。
关于java - sqlMapClient.startTransaction() - 案例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30995564/