读书人

怎么使用两个这样的结果集高手指教!

发布时间: 2011-12-30 23:30:45 作者: rapoo

如何使用两个这样的结果集,高手指教!!!
<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* " errorPage= " " %>
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 显示主题 </title>
</head>
<body onLoad= "clockon(bgclock); ">
<jsp:useBean id= "connection " scope= "request " class= "com.JDBConnection "/>
<table width= "777 " height= "33 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 " background= "image/navigation3.jpg ">
<tr>
<td>      <font color= "#FFFFFF "> ≡ JSP 专区 ≡ </font> </td>
</tr>
</table>
<table width= "777 " border= "1 " align= "center " cellpadding= "0 " cellspacing= "0 " bordercolor= "#FFFFFF " bordercolordark= "#9EA5D1 " bordercolorlight= "#FFFFFF " >
<tr align= "center ">
<td width= "47 " height= "25 " background= "image/bg_Navigate.GIF "> 状态 </td>
<td width= "351 " background= "image/bg_Navigate.GIF "> 主题 </td>
<td width= "140 " background= "image/bg_Navigate.GIF "> 发布人 </td>
<td width= "78 " background= "image/bg_Navigate.GIF "> 回复数量 </td>
<td width= "149 " background= "image/bg_Navigate.GIF "> 发布时间 </td>
</tr>
<%
String sqlTitle= "select * from tb_forumSend order by id desc ";
ResultSet rsTitle=connection.executeQuery(sqlTitle);
String number= " ";
String id= " ";
try{
while(rsTitle.next()){
id=rsTitle.getString( "id ");
//String sqlBack= "select count(*) as number from tb_forumBack where id= ' "+id+ " ' ";

//ResultSet rsBack=connection.executeQuery(sqlBack);
//while(rsBack.next()){
//number=rsBack.getString( "number ");
//}
%>
<tr align= "center ">
<td height= "30 "> <img src= "image/reader.gif "> </td>
<td align= "left ">   <a href= "showContent.jsp?id= <%=id%> "> <%=rsTitle.getString( "title ")%> </a> </td>
<td> <%=rsTitle.getString( "account ")%> </td>

<td> <%//=number%> </td>

<td> <%=rsTitle.getString( "creatime ")%> </td>
</tr>
<%}}catch(Exception e){}%>


connection.closeConnection();
</table>
</body>
</html>

运行是一但刷新,屏幕就什么都没了o(∩_∩)o...
我试了,肯定是注释里的内容又问题,
可是又不知道如何解决,试了 n回都不行啊!

[解决办法]
<%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* " errorPage= " " %>
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 显示主题 </title>
</head>
<body onLoad= "clockon(bgclock); ">
<jsp:useBean id= "connection " scope= "request " class= "com.JDBConnection "/>
<jsp:useBean id= "connection1 " scope= "request " class= "com.JDBConnection "/>
<table width= "777 " height= "33 " border= "0 " align= "center " cellpadding= "0 " cellspacing= "0 " background= "image/navigation3.jpg ">
<tr>
<td>      <font color= "#FFFFFF "> ≡ JSP 专区 ≡ </font> </td>
</tr>
</table>
<table width= "777 " border= "1 " align= "center " cellpadding= "0 " cellspacing= "0 " bordercolor= "#FFFFFF " bordercolordark= "#9EA5D1 " bordercolorlight= "#FFFFFF " >
<tr align= "center ">
<td width= "47 " height= "25 " background= "image/bg_Navigate.GIF "> 状态 </td>
<td width= "351 " background= "image/bg_Navigate.GIF "> 主题 </td>
<td width= "140 " background= "image/bg_Navigate.GIF "> 发布人 </td>
<td width= "78 " background= "image/bg_Navigate.GIF "> 回复数量 </td>
<td width= "149 " background= "image/bg_Navigate.GIF "> 发布时间 </td>
</tr>
<%
String sqlTitle= "select * from tb_forumSend order by id desc ";
ResultSet rsTitle=connection.executeQuery(sqlTitle);
String number= " ";
String id= " ";
try{
while(rsTitle.next()){
id=rsTitle.getString( "id ");
String sqlBack= "select count(*) as number from tb_forumBack where id= ' "+id+ " ' ";

ResultSet rsBack=connection1.executeQuery(sqlBack);//另一个
while(rsBack.next()){
number=rsBack.getString( "number ");
}
%>
<tr align= "center ">
<td height= "30 "> <img src= "image/reader.gif "> </td>
<td align= "left ">   <a href= "showContent.jsp?id= <%=id%> "> <%=rsTitle.getString( "title ")%> </a> </td>
<td> <%=rsTitle.getString( "account ")%> </td>

<td> <%//=number%> </td>

<td> <%=rsTitle.getString( "creatime ")%> </td>
</tr>
<%}}catch(Exception e){}%>
connection.closeConnection();
</table>
</body>
</html>

读书人网 >Java Web开发

热点推荐