求救!必给分.....
以下程序为什么在for循环中加入一个读取数据的语句,这段循环就不能运行下去呀?
<%@ page import="java.sql.*" %>
<%
PreparedStatement stmt=null;
int maxNum=0;
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
}
catch (Exception E) {
out.println("Unable to load driver.");
}
try {
Connection C = DriverManager.getConnection("jdbc:mysql://localhost/22dd?user=fdf&password=1111&useUnicode=true&characterEncoding=8859_1");
Statement s=C.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=s.executeQuery("select * from bulletin where mod = 0");
rs.last();
int no_top;
no_top = rs.getRow() + 1;
int i=1;
for (i=1;i<no_top;i++)
{
if (rs.absolute(i))
{
ResultSet thisnum=s.executeQuery("select count(*) from bulletin where mod = " + rs.getInt(1));
if (thisnum.next())
maxNum=thisnum.getInt(1);
%>
<tr align="center">
<td bgcolor="#FFFFFF" width="30">
</td>
<td bgcolor="#B5E7FF" width="30"><img src="images/icon12.gif" width="15" height="15"></td>
<td bgcolor="#FFFFFF"><a href=view.jsp?serial=<%=rs.getInt(1)%>><%=rs.getString(2)%></a></td>
<td bgcolor="#FFFFFF" width="30"><a href=view.jsp?serial=<%=rs.getString(1)%> target=_blank><img src=images/newwin.gif border=0></a></td>
<td bgcolor="#B5E7FF"><a href=mailto:<%=rs.getString(5)%>><%=rs.getString(3)%></a></td>
<td bgcolor="#FFFFFF" width="30"><%=rs.getString(8)%></td>
<td bgcolor="#B5E7FF" width="30"><%=rs.getString(8)%></td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<%
}
else
{
break;
}
}
rs.close();
s.close();
C.close();
}
catch (SQLException E) {
out.println("SQLException: " + E.getMessage());
out.println("SQLState: " + E.getSQLState());
out.println("VendorError: " + E.getErrorCode());
}
%>