문제

I would like to use connection pool for a web app and mysql dbms. If I have want to force the connection to set autocommit to false for a particular method, is it possibile that this connection (with autocommitt off) is used by other requests?

도움이 되었습니까?

해결책

is it possibile that this connection (with autocommitt off) is used by other requests?

You should always retrieve the Connection in the narrowest scope, this means, preferably as a local variable for your methods. Then, you can turn autocommit off by calling Connection#setAutocommit with false, and after using the connection object, close it. Note that this will only affect the current transaction and other requests won't be affected.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top