最好不要将connection 和close()分开,使用完毕就关闭,这样不容易出问题。
Connection conn = null;
try{
....
rs.close();
stmt.close();
.....
}catch(Exception e){}
finally{
if(conn!=null)
try{
conn.close();
}catch(Exception e){}
}

解决方案 »

  1.   

    楼上的兄弟,如果照你这么做,那么结果集就返回不了了。因为执行try里的内容后就要关闭connection,那结果集也没有了,会取不出数据。
      

  2.   

    Bean中的close()写成这样试试:
     public  void  close(){  
                           try{  
                                       if(conn  !=  null){ 
     
                                                   rs.close();
                                                   stmt.close(); //在这里CLOSE
                                                   conn.close(); //在这里CLOSE
                                       }  
                           }catch(Exception  ee){  
                                       System.err.println("close():"  +  ee.getMessage());  
                           }  
               }  
    }  
      

  3.   

    在rs关闭前,把rs内容转到一个对象中,等conn.close()以后返回对象。