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?
SET AUTOCOMMIT OFF ;
(as i see,) You have three options:
jdbc:h2:./foo/bar;AUTOCOMMIT=OFF
SET AUTOCOMMIT OFF
(possible values: TRUE | ON | FALSE | OFF
, not supported in cluster mode)java.sql/
)Connection.setAutoCommit(false)
Refs: