粗看了一下:
1.mobile2可能会未初始化(赋值)就做比较mobile2.equals(MOBILE[i])
2.没有处理异常的代码
3.String sel = "select MOBILE from APP_XCBN_CONTENT WHERE MOBILE = " + MOBILE[i];
最后改为String sel = "select MOBILE from APP_XCBN_CONTENT WHERE MOBILE = '" + MOBILE[i] + "'";

解决方案 »

  1.   

    for (int i = 0;i < 10;i++){
       int len_m = MOBILE[i].length();

    if (len_m != 11){
    msg = "手机号输入有误!请确认重新输入";
    //temp = 0;
    break;
        }        //把此处的}移至最后,让MOBILE[i]处于for循环中

        String sel = "select MOBILE from APP_XCBN_CONTENT WHERE MOBILE = " + MOBILE[i];
    ResultSet qs = stmt.executeQuery(sel);

    while(qs.next()){
    mobile2 = qs.getString("MOBILE");
    }
    if (mobile2.equals(MOBILE[i])){
    msg = "有错误发生";
    }else{

    String insert = "INSERT INTO APP_XCBN_CONTENT(MOBILE)VALUES('" + MOBILE[i] + "')";
    stmt.executeUpdate(insert);
    msg = "插入成功!";
    temp = 0;
    }

    }
      

  2.   

    修改一下循环体:
    while(qs.next()){
    mobile2 = qs.getString("MOBILE");
    if (mobile2.equals(MOBILE[i])){
    msg = "有错误发生";
                                         break;
    }
                      }
    if(qs==null){  //说明没有重复的手机号,qs已到最后
    String insert = "INSERT INTO APP_XCBN_CONTENT(MOBILE)VALUES('" + MOBILE[i] + "')";
    stmt.executeUpdate(insert);
    msg = "插入成功!";
    temp = 0;
       }
      

  3.   

    while(qs.next()){
    mobile2 = qs.getString("MOBILE");
    }
    if (MOBILE[i].equals(mobile2)){
    msg = "插入成功!";
    }else{

    String insert = "INSERT INTO APP_XCBN_CONTENT(MOBILE)VALUES('" + MOBILE[i] + "')";
    stmt.executeUpdate(insert);
    msg = "插入成功!";
    temp = 0;
    }
    }
    楼上那位大哥:要是按你写的那样,那重复的手记号后面不重复的怎么办?
      

  4.   

    NICK 的我测试通过了,谢谢老大啊 哈哈哈哈