sqlh2autocommit

Turn off AUTOCOMMIT in H2 Database Engine via SQL rather than via Java method


How can I turn off AUTOCOMMIT in H2 via SQL?

I want to start a transaction while using H2 from JDBC. I understand that in JDBC we do not use BEGIN TRANSACTION calls in SQL. Instead we merely disable auto-commit.

So how to turn off auto-commit in a JDBC session with H2?

I see some setAutoCommit( boolean ) methods on classes such as Session. Must I use one of those as a Java call?

Is there some SQL statement that I can use in my embedded SQL in my JDBC code?


Solution

  • SET AUTOCOMMIT OFF ;

    (as i see,) You have three options:

    Refs: