该函数在被调用的时候第一次能正常执行循环,当执行第二遍的时候就跳出循环体了,不执行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在另外一个函数里面已经连接过了
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在另外一个函数里面已经连接过了
这句select语句查询出的结果应该只有一条吧
结果集里只有一条数据,所以在rs.next()之后,已经没有数据了,那就自然跳出循环了啊
在while语句块中加一句
if(rs.isLast()){
System.out.println(rs.getRow());
}
如果打印了这句话就说明程序是正常结束的
看看什么结果?