Note that there are some explanatory texts on larger screens.

plurals
  1. POExecute all Query or Nothing Should get executed
    text
    copied!<p>Well Try to Format Ques.I have set of Queries mentioned below.Now i want to have some functionality which can ensure either all query should execute or not even one(if some kind of error occur) i just want to maintain my database in proper state.</p> <pre><code> con.setAutoCommit(false); String qry = "insert into tblAllotment(Employee_ID,Employee_Name,Area,Building_Name,Flat_Type,Flat_No,Date_Application,Date_Allotment,Admin_Code) values(" + id + ",'" + name[1] + "','" + area + "','" + flat[2] + "','" + flat[1] + "','" + flat[0] + "','" + dte + "','" + date + "'," + uid + ")"; String qry1 = "insert into tblFlat_Report(Flat_No,Area_Code,Employee_ID,Date_Allottment,Admin_Code)values('" + flat[0] + "'," + acode + "," + id + ",'" + date + "'," + uid + ")"; //String qry2="UPDATE tblUser_Report t1 JOIN (SELECT MAX(S_Date) s_date FROM tblUser_Report WHERE Employee_ID = "+id+") t2 ON t1.s_date = t2.s_date SET t1.Status = 'A', t1.S_Date ='"+date+"' WHERE t1.Employee_ID ="+id+""; String qry2 = "insert into tblUser_Report(Employee_ID,Employee_Name,S_Date,Area,Status) values(" + id + ",'" + name[1] + "','" + date + "','" + area + "','A')"; String qry3 = "update tblFlat set Status ='A' where Flat_No='" + flat[0] + "' AND Area_Code=" + acode + " "; String qry4 = "update tblUser set WL_Flag='N' where Employee_ID=" + id + ""; st = con.createStatement(); int i = st.executeUpdate(qry); int j = st.executeUpdate(qry1); int k = st.executeUpdate(qry2); int l = st.executeUpdate(qry3); int m = st.executeUpdate(qry4); con.commit(); if (i != 0 &amp; j != 0 &amp; k != 0 &amp; l != 0 &amp; m != 0) { Done = "Data Inserted Successfully...!!!"; } else { System.out.println("Error Occured"); } } catch (SQLException e) { con.rollback(); System.out.println(e.getMessage()); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload