按,批量删除数据的方法

来源:互联网 发布:电信通网络怎么样 编辑:程序博客网 时间:2024/05/12 21:58

/**
  * 批量删除用户
  * @param request
  * @param response
  * @throws Exception
  * @throws ServletException
  * @throws IOException
  * return boolean
  */
 public boolean batchdel(String Ids)throws Exception{
  logger.debug("ids:4545" );
         String sql;
         String temp;
   int i;int start,end;
   
   for(i=0;i<Ids.length();i++)
   {
    start=i;
    end=Ids.indexOf(",", start);
    if(end!=-1)
    {
    temp=Ids.substring(start, end);
  
    sql="delete from  t_user_info where user_id="+Integer.parseInt(temp);
    executeUpdate(sql);
    i=end;
    start=end;
    }
    else
    {
     temp=Ids.substring(start, Ids.length());
    
     sql="delete from  t_user_info where user_id="+Integer.parseInt(temp);
     executeUpdate(sql);
     break;
    }
     
   }
  //StringBuffer buffer = new StringBuffer();

  //buffer.append("delete from  t_user where u_id in(").append(ids).append(")");
  return true;
 }

原创粉丝点击