<%@ page language="java" import="java.sql.*" pageEncoding="GB18030"%>
<%request.setCharacterEncoding("gb2312");%>
<html>
 <head>
 </head>
  
 <body bgColor=#4e7dd1>
<form action="webedit.jsp" method="post">
<table align="center">
<tr><td align="center"><FONT style="FONT-SIZE: 15pt" color=#eff5fa>后台网络收藏夹管理</FONT></td></tr>
<jsp:useBean id="resource" scope="page" class="sju.sjumis.yuanding.util.TeacherDBBean"></jsp:useBean>
<%String address = request.getParameter("webaddress");
String name = "benwei";
ResultSet rs = resource.executeQuery("select * from collectioncontent where hrefaddress='"+address+"' and username='" +name+"'");
if(rs.next())
{%>
<tr><td>网站名称:</td><td><input type="text" name="text1" value=<%=rs.getString("webname")%>></td></tr>
<tr><td>网站地址:</td><td><input type="text" name="text2" value=<%=rs.getString("hrefaddress")%>></td></tr>
<tr><td>网站名称:</td><td><input type="text" name="text3" value=<%=rs.getString("re")%>></td></tr>
<tr><td><input type="hidden" name="text4" value=<%=rs.getString("hrefaddress")%>></td></tr>
<%}
else
{%>
<tr><td>网站名称:</td><td><input type="text" name="text1"></td></tr>
<tr><td>网站地址:</td><td><input type="text" name="text2"></td></tr>
<tr><td>网站名称:</td><td><input type="text" name="text3"></td></tr>
<%}resource.closeStmt();%>
<tr>
    <td align="center"><input name="" type="submit" value="提交" /></td>
    <td align="center"><input name="" type="reset" value="重置" /></td>
   </tr>
   </table>
   <%
   String text1Value = request.getParameter("text1");
   String text2Value = request.getParameter("text2");
   String text3Value = request.getParameter("text3"); 
   String text4Value = request.getParameter("text4"); 
   if(text1Value == null && text1Value == null && text1Value == null)
   {
   ResultSet rw = resource.executeQuery("select * from collectioncontent where hrefaddress='"+address+"' and username='" +name+"'");
   if(rw.next())
   {
   if(rw.getString("webname").equals(text1Value) && rw.getString("hrefaddress").equals(text1Value) && rw.getString("re").equals(text1Value))
   out.print("<script>alert('请修改信息后再提交...');</script>");
   else
   {
   //out.print(text1Value+"<br>");out.print(text2Value+"<br>");out.print(text3Value+"<br>");out.print(text4Value+"<br>");
   resource.executeUpdate("update collectioncontent set webname='"+text1Value+"',hrefaddress='"+text2Value+"',re='"+text3Value+"' where hrefaddress='"+ text4Value + "' and username='" +name+"'");
out.print("<script>alert('信息也成功修改...');</script>");
out.print("<script>window.close();</script>");
   }
   }
   }
</form>
 </body>
</html>为什么第二个ResultSet rw执行不了...
因没有rs.next()是false
所以"if(rw.next()){...."下面都不执行了?

解决方案 »

  1.   

    if(text1Value  ==  null  &&  text1Value  ==  null  &&  text1Value  ==  null) 
    就为:
    if(text1Value  !=  null  &&  text1Value  !=  null  &&  text1Value  !=  null)
      

  2.   

    <%}resource.closeStmt();%> 
    ResultSet rw = resource.executeQuery("select * from collectioncontent where hrefaddress='"+address+"' and username='" +name+"'");
    if(rw.next())
    ---------------------------------
    关闭了,还用来执行?
      

  3.   

    <%}resource.closeStmt();%> 
    ResultSet rw = resource.executeQuery("select * from collectioncontent where hrefaddress='"+address+"' and username='" +name+"'");
    if(rw.next())
    ---------------------------------
    关闭了,还用来执行?
      

  4.   

    不是那个问题,解决了...
    又发现一个问题:从数据库取出来的字符串能不能和字符变量比较?即:
    rw.getString("webname").equals(text1Value)
      

  5.   

    异常都没有
    rw.getString("webname")取出来的值为空就不能比较了,会抛空指针异常。
      

  6.   

    iodsflksdflkdjslfksd lkfslkaf s
      

  7.   

    如果不空.(肯定不空)...
    text1Value是一次取出来的.
    再取一次比较为什么就不行了呢?
      

  8.   

    while(rw.next()){}循环结束后,rw的游标定位在结果集的最后了,第二次再读自然就没有数据了。可以在第二次读rw前把rw重定位到开始的位置就好。