public String[] deleteEPGroup(String groupID, String groupName) {
String[] operRes=new String[3];
if(!StringUtils.isEmpty(groupID)) {
operRes[0]="3";
operRes[1]=" I'm sorry , There is an error , Please try again or contact the administrator ";
operRes[2]=" Failed to delete sync address book group ";
Log.getInstance().printError(this.getClass().getName()," Delete synchronous address book group , Unable to get the GroupID");
return operRes;
}
// Validation of group name
if(groupName==null || "".equals(groupName)) {
// If the group name is empty, use Id Query in database
Log.getInstance().printInfo(this.getClass().getName(), " Delete synchronous address book group , Client failed to pass group name , Start querying the group name from the database ");
List<String[]> groupNameList=this.getGroupByID(groupID);
if(groupNameList==null)
{
operRes[0]="3";
operRes[1]=" I'm sorry , There is an error , Please try again or contact the administrator ";
operRes[2]=" Failed to delete sync address book group ";
Log.getInstance().printError(this.getClass().getName()," Delete synchronous address book group , according to ID Query group name , The database connection is null");
return operRes;
}
String[] groupNames=groupNameList.get(0);
if(groupNames==null || groupNames.length<2) {
operRes[0]="3";
operRes[1]=" I'm sorry , There is an error , Please try again or contact the administrator ";
operRes[2]=" Failed to delete sync address book group ";
Log.getInstance().printError(this.getClass().getName()," Delete synchronous address book group , according to ID Query group name the array returned by the query is empty or less than 2");
return operRes;
}
if(groupNames[1]!=null &&"".equals(groupNames[1])) {
groupName=groupNames[1];
} else {
operRes[0]="3";
operRes[1]=" I'm sorry , There is an error , Please try again or contact the administrator ";
operRes[2]=" Failed to delete sync address book group ";
Log.getInstance().printError(this.getClass().getName()," Delete synchronous address book group , according to ID The query group name is null Or empty ");
return operRes;
} }
//groupID and groupName After all of them are not empty, proceed to the next step
// Find out the synchronous address book group in the database
List<String[]> groupList=this.getALLGroup();
if(groupList==null){
operRes[0]="3";
operRes[1]=" I'm sorry , There is an error , Please try again or contact the administrator ";
operRes[2]=" Delete sync address book "+groupName+" Group failed ";
Log.getInstance().printError(this.getClass().getName()," Delete synchronous address book group , Query all synchronous address book groups, send error ");
return operRes;
}
// Create a List Store the group to be deleted and all the subgroups under the group Id
List<String> groupIDList=new ArrayList<String>();
//groupIDList Store all the groups to be deleted ID That is, reorganization and all its subgroups
groupIDList=findAllChildrenGroupID(groupList, groupIDList, groupID);
Connection conn=null;
PreparedStatement pst=null;
Statement st=null;
try{
conn=DataBaseManage.getInstance().getConnection();
st=conn.createStatement();
conn.setAutoCommit(false);
//count It's a counter
int count=0;
for(int i=0;i<groupIDList.size();i++){
// When group ID Not empty
if(groupIDList.get(i)!=null &&!"".equals(groupIDList.get(i))){
// Delete the group
String deleteGroupSQL="DELETE FROM t_enterprisebookgroup WHERE GroupID='"+groupIDList.get(i)+"'";
st.addBatch(deleteGroupSQL);
// Delete members of this group
String deleteContactSQL="DELETE FROM t_enterprisegroupmembers WHERE EnterpriseGroupID='"+groupIDList.get(i)+"'";
st.addBatch(deleteContactSQL);
count++;
}
}
// If there is data to be executed in the batch, the batch operation will be executed
if(count>0){
st.executeBatch();
}
conn.commit();
conn.setAutoCommit(true);
Log.getInstance().printInfo(this.getClass().getName(), " Delete synchronous address book group "+groupName+" success ");
operRes[0]="1";
operRes[1]=" Delete synchronous address book group "+groupName+" success ";
operRes[2]=" Delete synchronous address book group "+groupName+" success ";
return operRes;
}catch(Exception ex){
ExceptionHeading.getException(this.getClass().getName(), ex, " Delete synchronous address book group , Transaction operation execution failed , The transaction begins to go back on track ");
try{
// Back on track
conn.rollback();
Log.getInstance().printInfo(this.getClass().getName(), " Delete synchronous address book group , The transaction went back to track successfully ");
operRes[0]="3";
operRes[1]=" I'm sorry , There is an error , Please try again or contact the administrator ";
operRes[2]=" Delete sync address book "+groupName+" Group failed ";
return operRes;
} catch(Exception e){
// Transaction derailment failed
ExceptionHeading.getException(this.getClass().getName(), ex, " Delete synchronous address book group , Transaction operation back to orbit failed ");
operRes[0]="3";
operRes[1]=" I'm sorry , There is an error , Please try again or contact the administrator ";
operRes[2]=" Delete sync address book "+groupName+" Group failed ";
return operRes;
}
} finally{
DataBaseManage.getInstance().closeStatement(pst);
DataBaseManage.getInstance().closeStatement(st);
DataBaseManage.getInstance().releaseConnection(conn);
}
}

java_method_ Delete more articles about transaction rollback

  1. 【Java EE Study 19】【 Use filters to achieve total station compression 】【 Use ThreadLocal Patterns solve cross DAO Transaction rollback problem 】

    One . Use filters to achieve total station compression 1. The goal is : All about the site JSP Page compression , Reduce the use of user traffic . But don't compress pictures and videos , Because the compression ratio of pictures and videos is very small , And the server resources needed for processing are very large . 2. Realization principle : ...

  2. mysql database Indexes Transaction and transaction rollback

    mysql Indexes Index is equivalent to the catalogue of books : Speed up the query speed of data : Take up physical storage space , add to , Delete , It slows down writing Look at the index used by the table mysql> show index from Table name \G;(\G The branch shows ...

  3. [SQL] Transaction rollback details and examples

    In a stored procedure SET XACT_ABORT ON And transaction Write... In a stored procedure SET XACT_ABORT ON What's the usage? ? SET XACT_ABORT ON Is to set transaction rollback ! When it comes to ON when , If you store ...

  4. Why? mysql After the transaction is rolled back , Self increasing ID Still growing

    After the transaction is rolled back , Self increasing ID Still increasing , After rollback , Self increasing ID Still increasing . Such as the current ID yes 7, After inserting a piece of data , It's rolling back . Then you insert another piece of data , The insertion is successful , This is your ID No 8, It is 9. Because even though you inserted the rollback before , however ID also ...

  5. springboot Transaction rollback

    stay springboot in , When using transaction rollback , add to @Transactional annotation , And then in try-catch In block , When something goes wrong , stay catch in add to TransactionAspectSupport.cur ...

  6. mysql Classification and transaction rollback

    primary coverage : *** Data definition language DDL a key *** Data manipulation language DML a key Data query language DQL a key --- Transaction control language TCL --- Database control language DCL --- Primary key (primary key) --- Data redundancy ...

  7. [ turn ] C# mysql Transaction rollback

    What is a database transaction A database transaction is a series of operations performed as a single logical unit of work . Imagine an online shopping transaction , The payment process at least includes the following steps of database operation : · Update inventory information of products purchased by customers · Save customer payment information -- May include ...

  8. ThinkPHP Implementation of transaction rollback sample code

    ThinkPHP An example of transaction rollback for is as follows : ? 1 2 3 4 5 6 7 8 9 10 $m=D('YourModel');// Or is it M(); $m2=D('YouModel2'); $m->sta ...

  9. Spring in @Transactional Transaction rollback

    Reprint : Spring in @Transactional Transaction rollback One . Use scenario example In understanding @Transactional We have to know before we can use it @Transactional What's the usage? . Here's a chestnut : Like a department ...

Random recommendation

  1. win7/8 Next VirtualBox fictitious Ubuntu Shared folder settings

    Experimental environment : host :win8.1 Virtual machine software :VirtualBox4.3 Virtual host :centos6.5 final Close test available ! 1.  Install the enhancement pack (VBoxGuestAdditions)  Turn on Virtual ...

  2. PHP ServerPush

    original text :http://yorsal.com/archives/302 With people's awareness of Web The increasing demand for instant applications ,Server Push( push ) Technology is chatting . News alerts, especially social networks, are on the rise , Become a real-time application ...

  3. struts2 use convention-plugin Achieve zero configuration

    Recently, I began to pay attention to struts2 New features , From this version ,Struts Start using convention-plugin Instead of codebehind-plugin To achieve struts Zero configuration of . The profile is streamlined , It's really simple ...

  4. The baby python Deep as the sea -- Shallow copy and deep copy

    python There's a module in copy,deepcopy Function for deep copy ,copy Function for shallow copy . To understand shallow copy , We have to find out first python Citation in . quote Python Everything in is the object , Variables hold references to objects ...

  5. About pydev Syntax error tips for

    When a third party package is introduced ,eclipse By default, some packages will be set as wrong , The error is :“undefined variable from import...” It's actually right , But it's a mistake , Is very boring resolvent :window -- pr ...

  6. analysis SNS Social system &quot;ThinkSNS V4&quot; And &quot;ThinkSNS+&quot; The difference between

    ThinkSNS What is it? ? ThinkSNS( abbreviation TS), A full platform comprehensive sns Social system , To provide social software research and development and technical solutions for domestic and foreign small and medium-sized enterprises and entrepreneurs , The latest version is ThinkSNS+( abbreviation TS+), Also known as ...

  7. Beginning Math and Physics For Game Programmers (Wendy Stahler Writing )

    Chapter 1. Points and Lines ( Already seen ) Chapter 2. Geometry Snippets ( Already seen ) Chapter 3. Trigonometry Snippets  ...

  8. self-taught Aruba5.3.3-Aruba Safety certification - Yes PEFNG Authentication configuration for the license environment Captive-Portal

    Click on the return : self-taught Aruba The way self-taught Aruba5.3.3-Aruba Safety certification - Yes PEFNG Authentication configuration for the license environment Captive-Portal 1. Captive-Portal Authentication configuration foreword 1.1  newly build ...

  9. expdp、impdp Use

    expdp Introduce EXPDP Command line options 1. ATTACH This option is used to establish an association between a client session and an existing export role . The grammar is as follows ATTACH=[schema_name.]job_nameSchema_name Is used to specify the ...

  10. mac Use pf Do port forwarding

    Mac os I found that direct input localhost Access is denied , The reason lies in OSX about 1024 The internal port needs root jurisdiction , So we need to make a 80 Port forwarding . Once the ipfw Has been pf Replaced by . First of all, we need to ...