mysql - Java: Rollback Database updates? -


I got three ways, with a current save the node database, desired effect of not changing Does not receive until all the writing is successful.

  conn.setAutoCommit (false); WriteNodeTable (node, new nodeNID); WriteContentTypeBoutTable (node, newNodeNID); Instruments (node, new node nid); Conn.commit ();  

If the second is a problem in the third method (such as that put an exception exception), so I want to roll back all the changes.

  private Whaid list Tirms (Drupanl node, Aianti New Nodanaidi) throws Skyuelksepshn  

This is a DB writing: String sql = "Trm_anod (NID, Weed , TID) include values ​​(?,?,?) "; Submit Prepared Placement = conn.prepareStatement (sql); Prep.setInt (1, newNodeNID); Prep.setInt (2, newNodeNID); String School name = words. Help school Ofagainst (Nodkget (Bitafild.aganst)); Prep.setString (3, SchoolName); Prep.execute (); String Fencernames = words help Fensrofagenst (Nodkget (BoutField.against)); Prep.setString (3, FencerName); Prep.execute (); Prep.close (); }

You can use rollback method Connection interface

In addition, you have to set setAutoCommit to false and call commit And the rollback methods are appropriate.


Comments

Popular posts from this blog

php - multilevel menu with multilevel array -

c# - TypeConverter in propertygrid only converts from string, not to -

jQuery UI: Datepicker month format -