Your example with multiple "begins" indicates a desire to have nested
transactions. AFAIK, SQL does not support that and JDBC drivers will
throw exceptions if you try it.  Some database engines support
"savepoints" or "checkpoints" providing a roughly equivalent functionality.

Your last statement that "it solves only mistakes durring queries" is
incorrect.  A single rollback statement will undo all the updates back
to the beginning of the transaction. Experiment with a database that
supports Transactions and this will become clear.

Paul Copeland, JOT Object Technologies - http://www.jotobjects.com

----------------------------------------------------------------------

Date:    Tue, 26 Nov 2002 09:06:50 +0100
From:    Jiri Chaloupka <[EMAIL PROTECTED]>
Subject: Re: Off-topic: JSP and MySQL

It solves only mistakes durring queries, not automatic rollabks from
concurrently transactions ...

Jiri Chaloupka

<citováno kdo="Emmanuel Eze">

Why not try this approach:

try
(
       conn.setAutoCommit(false);
       stmt.execute(.....);
       stmt.execute(.....);
       stmt.exexute(....);
       conn.commit();
)
catch (SQLException slqe)
{
       conn.rollback();
}

finally
{
       conn.setAutoCommit(true);
       stmt.close;
       conn.close();
}

Emma

-----Original Message-----
From: Jiri Chaloupka [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 25, 2002 9:35 AM
To: [EMAIL PROTECTED]
Subject: Re: Off-topic: JSP and MySQL


I do not know mySQL well, see manual page, looking for transactions.
(begin - commit - rollback - if it is supported ...)

boolean doit = true;
stm.execute("begin");
stm2.execute("begin");
stm3.exexute("begin");
if(!stm.execute("insert into ...")){
doit = false;
}
if(!stm2.execute("insert into ...")){
doit = false;
}
if(!stm3.execute("insert into ...")){
doit = false;
}
if(doit){
stm.execute("commit");
stm2.execute("commit");
stm3.execute("commit");
}else{
stm.execute("rollback");
stm2.execute("rollback");
stm3.execute("rollback");
}

Jiri Chaloupka



--
Jiri Chaloupka
B2BExpander.com
[EMAIL PROTECTED]
**********************************************
http://www.b2bexpander.com/
http://www,chalu.cz
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com

Reply via email to