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

Fred Toussi via Hsqldb-user <[email protected]> Sun, 05 May 2019 09:17:26 -0400
Newsgroups gmane.comp.java.hsqldb.user
Message-ID <[email protected]>
If you post an example PROCEDURE, I will check it.

On Sun, May 5, 2019, at 14:02, Jorge Garcia de Alba wrote:
> Procedures are sql-invoked routines and I use callablestatement to
> call them. When I cause an exception as a debugging measure I expect
> for database changes to rollback but it is not happening even if
> connection.setAutoCommit(false).
> 
> On 5/5/19, Fred Toussi via Hsqldb-user
> <[email protected]> wrote:
> > It is not clear what you mean by procedures. How do you call the
> > procedures?
> >
> > All procedures have BEGIN ATOMIC in their declaration. If there is an
> > exception inside the procedure, for example by a constraint violation, the
> > work of the procedure is rolled back. The exception is then thrown as an
> > SQLException by the JDBC CallableStatement method that was called.
> >
> > If you want to throw an exception in the procedure, use the SIGNAL
> > statement:
> > SIGNAL SQLSTATE <state value>
> >
> >
> > On Sun, May 5, 2019, at 11:31, Jorge Garcia de Alba wrote:
> >> When I use connection.setAutoCommit(false), run my procedures and
> >> cause an exception it is not rolling back so I was wondering if I
> >> missed a configuration setting or something.
> >>
> >> On 5/5/19, Fred Toussi via Hsqldb-user
> >> <[email protected]> wrote:
> >> > 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
> >> >>
> >> >
> >> >
> >> > _______________________________________________
> >> > Hsqldb-user mailing list
> >> > [email protected]
> >> > https://lists.sourceforge.net/lists/listinfo/hsqldb-user
> >> >
> >>
> >>
> >> _______________________________________________
> >> Hsqldb-user mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/hsqldb-user
> >>
> >
> >
> > _______________________________________________
> > Hsqldb-user mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/hsqldb-user
> >
> 
> 
> _______________________________________________
> Hsqldb-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/hsqldb-user
>