当前位置: 代码迷 >> Java Web开发 >> 提问:ResultSet在if语句中不可操作?解决思路
  详细解决方案

提问:ResultSet在if语句中不可操作?解决思路

热度:70   发布时间:2016-04-17 14:54:25.0
提问:ResultSet在if语句中不可操作?
<%
        String   idno=request.getParameter( "searchidno ");     //获取提交的身份证号
        String   name=request.getParameter( "searchname ");       //获取提交的姓名
        String   origin=request.getParameter( "searchorigin ");   //获取提交的籍贯
        if(idno==null){idno= " ";}
        byte   b[]=idno.getBytes( "ISO-8859-1 ");
        idno=new   String(b);        
        if(name==null){name= " ";}
        byte   c[]=name.getBytes( "ISO-8859-1 ");
        name=new   String(c);
        if(origin==null){origin= " ";}
        byte   d[]=origin.getBytes( "ISO-8859-1 ");
        origin=new   String(d);
       
       
       
        String   sql1= "select   *   from   basic   where   idno= ' "+idno+ " ' ";
        String   sql2= "select   *   from   basic   where   name= '% "+name+ "% ' ";
        String   sql3= "select   *   from   basic   where   origin= ' "+origin+ " ' ";
        String   sql4= "select   *   from   basic   where   idno= ' "+idno+ " '   and   name= '% "+name+ "% ' ";
        String   sql5= "select   *   from   basic   where   idno= ' "+idno+ " '   and   origin= ' "+origin+ " ' ";
        String   sql6= "select   *   from   basic   where   name= '% "+name+ "% '   and   origin= ' "+origin+ " ' ";
        String   sql7= "select   *   from   basic   where   idno= ' "+idno+ " '   and   name= '% "+name+ "% '   and   origin= ' "+origin+ " ' ";
      CONTROLDB   con=new   CONTROLDB();
      ResultSet   rs;
      if(idno== " "   &   name== " "   &   origin== " "){response.sendRedirect( "basicsearcherror.jsp ");}
      else   if(idno== " "   &   name== " "   &   origin!= " "){ResultSet   rs=con.executeQuery(sql3);}
      else   if(idno== " "   &   name!= " "   &   origin== " "){ResultSet   rs=con.executeQuery(sql2);}
      else   if(idno!= " "   &   name== " "   &   origin== " "){ResultSet   rs=con.executeQuery(sql1);}
      else   if(idno!= " "   &   name!= " "   &   origin== " "){ResultSet   rs=con.executeQuery(sql4);}
      else   if(idno!= " "   &   name== " "   &   origin!= " "){ResultSet   rs=con.executeQuery(sql5);}
  相关解决方案