现在的位置: 首页 > 综合 > 正文

按,批量删除数据的方法

2018年04月15日 ⁄ 综合 ⁄ 共 825字 ⁄ 字号 评论关闭

/**
  * 批量删除用户
  * @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;
 }

抱歉!评论已关闭.