关于while循环的问题,给50分
请高手帮忙看一段代码,应该显示出三条记录的,但是只显示一条记录,循环只执行了一次,如果把if之中的语句去掉,就能正常显示三条记录,还发现如果if里边有数据库查询语句的话,也只能执行一次循环,sql语句应该没有错误,想请各位高手看看到底如何修改循环才能正常执行,多谢了!
String begin_time="";
String glnum="";
String jh="";
rs = stmt.executeQuery("SELECT GLNUM,jh,BEGIN_TIME from zqrb where rq=to_date( '"+date1+"','YYYY-MM-DD')");
while (rs.next())
{
j=j+1;
begin_time=rs.getString("begin_time");
glnum=rs.getString("glnum");
jh=rs.getString("jh");
if(begin_time==null)
{
rs1 = stmt.executeQuery("select max(rq) as maxrq from zqrb where rq<to_date('"+date1+"','YYYY-MM-DD') and begin_time is not null and glnum='"+glnum+"' and jh='"+jh+"'");
while (rs1.next())
{
maxrq=rs1.getString("maxrq");
}
rs1.close();
date1=maxrq.substring(0,10);
rs2 = stmt.executeQuery("select begin_time from zqrb where rq=to_date('"+date1+"','YYYY-MM-DD') and glnum='"+glnum+"' and jh='"+jh+"'");
while (rs2.next())
{
begin_time=rs2.getString("begin_time");
}
rs2.close();
}
%>
<%=glnum%>,<%=jh%>,<%=date1%>,<%=begin_time%><br>
<%
}
rs.close();
%>