String sel="select count(*) from guanyuanbiao where guoji='" + guoji + "' and zhiwei='01'";
rs=stmt.executeQuery(sel);
int ok=0;
if(!rs.next()){
   ok = getInt(1);
}
if (ok > 0 ) {
 wzg="insert into guanyuanbiao...
}

解决方案 »

  1.   

    update zhiwei where zhiwei<>'01'
    ……
      

  2.   

    不行,这里出错了。
    Generated servlet error:
    D:\java\tomcat\work\Standalone\localhost\_\lingshi\addokguanyuan$jsp.java:165: Method getInt(int) not found in class org.apache.jsp.addokguanyuan$jsp.
                       ok = getInt(1);
                                  ^
    Note: D:\java\tomcat\work\Standalone\localhost\_\lingshi\addokguanyuan$jsp.java uses or overrides a deprecated API.  Recompile with "-deprecation" for details.
    1 error, 1 warning
      

  3.   

    还是不行,这样增加不了记录了,guoji='" + guoji + "' and zhiwei='01'";是不是不能写在一起。
      

  4.   

    String sel="select count(*) from guanyuanbiao where guoji='" + guoji + "' and zhiwei='01'";
    rs=stmt.executeQuery(sel);
    int ok=0;
    while(rs.next()){
       ok = rs.getInt(1);
    }sel = "insert into guanyuanbiao..."
    if (ok > 0 ) {
     stmt.executeUpdate(sel);
    }
      

  5.   

    你好,感谢你给我的回复,还是不行的,这样可以运行,但判断失去效果,字段zhiwei有一个值为01,可是还可以增加的。