该函数在被调用的时候第一次能正常执行循环,当执行第二遍的时候就跳出循环体了,不执行while里的那段语句了,请各位帮忙看下是怎么回事。Statement stmt = this.myConnection.createStatement();
String sql = "select subject,mailfrom,mailto,content from spool_mail where id='"+ mailid +"'";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next())
{

String subject = rs.getString("subject");
String mailfrom = rs.getString("mailfrom");
String mailto = rs.getString("mailto");
String content = rs.getString("content");  }
this.myConnection.commit();
rs.close();
rs = null;
stmt.close();
stmt = null;  this.myConnection在另外一个函数里面已经连接过了 

解决方案 »

  1.   

    不明白代码的意思(while里面)
      

  2.   

    你把while 改成 if  看看行不行
      

  3.   

    select subject,mailfrom,mailto,content from spool_mail where id='"+ mailid +"'
    这句select语句查询出的结果应该只有一条吧
    结果集里只有一条数据,所以在rs.next()之后,已经没有数据了,那就自然跳出循环了啊
      

  4.   

    while (rs.hasNext())        
      

  5.   

    你的数据库中可能只有一条数据,
    在while语句块中加一句
    if(rs.isLast()){
        System.out.println(rs.getRow());
    }
    如果打印了这句话就说明程序是正常结束的
      

  6.   

     建议lz 在数据库命令行输入sql: select subject,mailfrom,mailto,content from spool_mail where id='"+ mailid +"' 
    看看什么结果?
      

  7.   

    rs记录集里如果只有一条记录的话,就只做一次了,你rs.next里面应该只有1条记录