public  static  boolean  deleteEmployee( String  empId )
{
PreparedStatement pstmt=null;
ResultSet rs=null;
try
{
String sql="delete from emp where empno=?";
pstmt=ConnectionFctory.getConnection().prepareStatement(sql);
pstmt.setInt(1, Integer.valueOf(empId));
rs=pstmt.executeQuery();

while(rs.next())
{
if(rs.getInt(Integer.valueOf(empId))!=0)
return true;
else
return false;
}
rs.close();
pstmt.close();

}catch(SQLException se)
{
System.out.println("删除员工出错!"+se.getMessage()); 
}
return false;
}各位前辈,为什么小弟运行后就出现:
删除员工出错!ORA-01002: 提取违反顺序???????????????????

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【goopoolzl】截止到2008-07-25 23:05:38的历史汇总数据(不包括此帖):
    发帖的总数量:12                       发帖的总分数:220                      每贴平均分数:18                       
    回帖的总数量:7                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:12                       结贴的总分数:220                      
    无满意结贴数:1                        无满意结贴分:20                       
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:100.00%                  
    无满意结贴率:8.33  %               无满意结分率:9.09  %                  
    敬礼!
      

  2.   

    ORA-01002: fetch out of sequence 
    Cause: This error means that a fetch has been attempted from a cursor which is no longer valid. Note that a PL/SQL cursor loop implicitly does fetches, and thus may also cause this error. There are a number of possible causes for this error, including: 1) Fetching from a cursor after the last row has been retrieved and the ORA-1403 error returned. 2) If the cursor has been opened with the FOR UPDATE clause, fetching after a COMMIT has been issued will return the error. 3) Rebinding any placeholders in the SQL statement, then issuing a fetch before reexecuting the statement.
    Action: 1) Do not issue a fetch statement after the last row has been retrieved - there are no more rows to fetch. 2) Do not issue a COMMIT inside a fetch loop for a cursor that has been opened FOR UPDATE. 3) Reexecute the statement after rebinding, then attempt to fetch again.
      

  3.   

    rs=pstmt.executeQuery(); 改为
    int delNum = pstmt.executeUpdate();
      

  4.   

    public  static  boolean  deleteEmployee( String  empId )
    {
    PreparedStatement pstmt=null;
    ResultSet rs=null;
    try
    {
    String sql="delete from emp where empno=?";
    pstmt=ConnectionFctory.getConnection().prepareStatement(sql);
    pstmt.setString(1, empId);
    int del=pstmt.executeUpdate();

    if(del!=0)
    {
    pstmt.close();
    return true;
    }
    else
    return false;
    }catch(SQLException se)
    {
    System.out.println("删除员工出错!"+se.getMessage()); 
    }
    return false;
    }是这样吗?
      

  5.   

    最好把pstmt.close();放在finally {}语句块里,而且还要要处理异常!