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

<citováno kdo="Deepak">
> Hi folks
>
> I guess this is off-topic. am sorry for that.
>
> Is it possible to execute a set of SQL statements in a batch using
JSP.
> The db is MySQL.
>
> I have 3 SQL statements. I want all of them to execute correctly.
> If one fails the others should be rolled back.
> its all or none.
>
> Is it possible?
>
> Thank you
> Deepak
>



--
Jiri Chaloupka
B2BExpander.com
[EMAIL PROTECTED]
**********************************************
http://www.b2bexpander.com/
http://www.chalu.cz - intranet groupware system

========================================================================
===
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

===========================================================================
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