Re: how do i start and end a transaction with hsqlb?

Fred Toussi via Hsqldb-user <[email protected]> Sun, 05 May 2019 04:51:25 -0400
Newsgroups gmane.comp.java.hsqldb.user
Message-ID <[email protected]>
A transaction is started when you execute the first insert, update or delete statement or procedure. The connection.commit() call commits the transaction. A connection.rollback() rolls it back to the start of the transaction. 

You just connect to your HSQLDB database to obtain your java.sql.Connection object and run your code. HSQLDB is always transaction but you can change the details if you want to. See the Guide, Sessions and Transactions chapter.

Fred Toussi

On Sun, May 5, 2019, at 03:41, Jorge Garcia de Alba wrote:
> Hello,
> 
> I would like to run a batch of statements and/or procedures and if
> there is an exception rollback.
> 
> Something like:
> 
>    try
>         {
>             connection.setAutoCommit(false);
>             //insert, update, delete statements and/or procedures
>             connection.commit();
>         }
>         catch (Exception e)
>         {
>             connection.rollback();
>         }
> 
> How do I setup hsqldb to do this?
> 
> jr
> 
> 
> _______________________________________________
> Hsqldb-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/hsqldb-user
>