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
Post a Comment