java - How to start a transaction in JDBC? -


connection.settransactionisolation(int) warns:

note: if method called during transaction, result implementation-defined.

this bring question: how begin transaction in jdbc? it's clear how end transaction, not how begin it.

if connection starts inside in transaction, how supposed invoke connection.settransactionisolation(int) outside of transaction avoid implementation-specific behavior?

answering own question:

  • jdbc connections start out auto-commit mode enabled, each sql statement implicitly demarcated transaction.
  • users wish execute multiple statements per transaction must turn auto-commit off.
  • changing auto-commit mode triggers commit of current transaction (if 1 active).
  • connection.settransactionisolation() may invoked anytime if auto-commit enabled.
  • if auto-commit disabled, connection.settransactionisolation() may invoked before or after transaction. invoking in middle of transaction leads undefined behavior.

sources:


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -