各位大侠,小的刚学JSP,现在在做一个小小的论坛,可是我在做的时候发现了这样一个问题,我把代码发上来
for (int i = 1; i <= rownum; i++) {
int tid = rs.getInt(1);
System.out.println(tid);
String name = rs.getString("title");
String zuozhe = rs.getString("name"); try {
rs1 = stmt//****
.executeQuery("select count(*) from neironglist where ziid="
//**** + tid);
rs1.next();
String k = rs1.getString(1);//**
getShowtable().append("<tr>");
getShowtable().append(
"<th width=100><div align=\"center\"><a href=\"neironglist.jsp?tid="
+ tid + "&page=1" + "\"> " + name
+ "</a></div></th>");
getShowtable().append(
"<th width=100><div align=\"center\">" + " "
+ zuozhe + "</div></th>");
getShowtable().append(
"<th width=100><div align=\"center\">" + k
+ "</div></th>");
getShowtable().append("</tr>");
rs.next();
} catch (Exception e) {
System.out.println(e.getMessage() + "666");
}
在我上面做//****这个记号的地方,不知道为什么只要我一加上就出现错误,去了就好了,这个功能就是查一下数据库把回复次数加上,可我怎么也没找出为什么,不好意思,先在这里谢谢了!
for (int i = 1; i <= rownum; i++) {
int tid = rs.getInt(1);
System.out.println(tid);
String name = rs.getString("title");
String zuozhe = rs.getString("name"); try {
rs1 = stmt//****
.executeQuery("select count(*) from neironglist where ziid="
//**** + tid);
rs1.next();
String k = rs1.getString(1);//**
getShowtable().append("<tr>");
getShowtable().append(
"<th width=100><div align=\"center\"><a href=\"neironglist.jsp?tid="
+ tid + "&page=1" + "\"> " + name
+ "</a></div></th>");
getShowtable().append(
"<th width=100><div align=\"center\">" + " "
+ zuozhe + "</div></th>");
getShowtable().append(
"<th width=100><div align=\"center\">" + k
+ "</div></th>");
getShowtable().append("</tr>");
rs.next();
} catch (Exception e) {
System.out.println(e.getMessage() + "666");
}
在我上面做//****这个记号的地方,不知道为什么只要我一加上就出现错误,去了就好了,这个功能就是查一下数据库把回复次数加上,可我怎么也没找出为什么,不好意思,先在这里谢谢了!
//****+ tid);
有问题
rs1 = stmt.executeQuery("select count(*) from neironglist“);// where ziid="+ tid);
.executeQuery("select count(*) from neironglist where ziid="
//****+ tid);
上面这句应该是SQL语法有错误,可能字符串有问题。
rs1.next();
String k = rs1.getString(1);//**
这句只要这样 if(rs1.next())基本就能够解决