since I still canβt comment, write the answer, just to comment on Vinegar's answer, the situation with setAutoCommit (), returning to the default state when the connection is returned to the pool, is not required behavior and should not be taken for granted, as well as closing statements and results; you can read that it should be closed, but if you do not close them, they will be automatically closed with the connection closed. Do not take this for granted, as it will use your resources in some versions of jdbc drivers.
We had a serious problem with the DB2 database on the AS400, the guys who needed transactional isolation called connection.setAutoCommit (false), and after shutting down they returned that connection to the pool (JNDI) without connection.setAutoCommit (old_state), so when another thread received this connection from the pool, they did not perform insertions and updates, and no one could understand why for a long time ...
source share