SQLException:Object has closed

阅读更多
 
  1. String insertRecordSql="select distinct depcity,arrcity,cabin,flightdate from TM_download where id>="+startId;  DBConnection  con=new DBConnection();  ResultSet record=con.executeQuery(insertRecordSql);  
  2. con=null;  
  3. con=new DBConnection();  
  4. String cabin;  
  5. String airline; 
  6. String update;//="update TM_download set price=";  
  7. try{  
  8.     while(record.next()){  
  9.          update="update TM_download set price=";  
  10.          cabin=record.getString("cabin");  
  11.          String depcity=record.getString("depcity");  
  12.          String arrcity=record.getString("arrcity");  
  13.          java.sql.Date flightdate=record.getDate("flightdate");  
  14.          airline=depcity+"-"+arrcity;  
  15.          Float cabinDisCoutF=(Float)cabinDiscount.get(cabin);  
  16.          Integer airlinePriceInt=(Integer)airlinePrice.get(airline);  
  17.          int cabinPrice=0;  
  18.          if(cabinDisCoutF!=null)  
  19.                         cabinPrice=getCommonPrice(airlinePriceInt.intValue(),cabinDisCoutF.floatValue());  
  20.          else  
  21.              cabinPrice=getSpecialcabinPrice(cabin,flightdate);  
  22.                     update=update+cabinPrice+" where cabin='"+cabin+"' and depcity='"+depcity+"' and arrcity='"+arrcity+"' and id>="+startId;     
  23.              con.executeUpdate(update);  
  24.              System.out.println("calculateCabinPrice sql:"+update);  
  25.       }  
  26. }catch(SQLException sqle){  
  27.      sqle.printStackTrace();  
  28. }finally{  
  29.      con.close();  

              程序缺少第3行时,整个while循环会执行一次,然后抛出Object  has closed 异常。具体原因还要进一步查证

你可能感兴趣的:(SQL)