java - setAutocommit(true) further explanations -


i have come across this oracle java tutorial. beginner in topic cannot grasp why it's needed set con.setautocommit(true); @ end of transaction.

here oracle explanation:

the statement con.setautocommit(true); enables auto-commit mode, means each statement once again committed automatically when completed. then, default state not have call method commit yourself. advisable disable auto-commit mode during transaction mode. way, avoid holding database locks multiple statements, increases likelihood of conflicts other users.

could explain in other words? bit:

this way, avoid holding database locks multiple statements, increases likelihood of conflicts other users.

what mean "holding database locks multiple statements"?

thanks in advance.

the database has perform row-level or table-level locking (based on database-engine in mysql) handle transactions. if keep auto-commit mode off , keep executing statements, these locks won't released until commit transactions. based on type, other transactions won't able update row/table locked. setautocommit(true) commits current transaction, releases locks held, , enables auto-commit, is, until further required, each individual statement executed , commited.

row-level locks protect individual rows take part in transaction (innodb). table-level locks prevent concurrent access entire table (myisam).


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -