Question on transaction in mysql

I am making an online shopping cart which is persistent.

On check Out I am taking all the items from shopping cart and looking for the number of quantities ordered for each item and accordingly decrementing the Inventory.

I am looping the whole thing which I described above. i.e I take an item from cart, look for number of items ordered and in very next line I execute an update statement to database.

I want to know if I use transaction ( mysql) then can I do the above thing successfully.

Like before I take anything from shopping cart I will write BEGIN statement. At the end I will make 2 forms one for submit and other for going to previous page which will have commit and rollback statements respectively.

Will this work. I have never used transactions thats why I have a doubt.

Please reply soon

[847 byte] By [aniketh_parmara] at [2007-11-27 4:06:35]
# 1
Hey can any one ans to my above question
aniketh_parmara at 2007-7-12 9:11:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
can u send datailed description or send codings
senthil_yogaa at 2007-7-12 9:11:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
You should use connection.setAutoCommit() to turn on and off auto commit which will allow this kind of behaviour.Read this recent post here: http://forum.java.sun.com/thread.jspa?threadID=5171572It cover's pretty much the same thing.
nogoodatcodinga at 2007-7-12 9:11:44 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...