JdbcOdbc的游标是不可以任意移动的

解决方案 »

  1.   

    代码如下:
    <%@ page contentType="text/html;charset=gb2312" %>
    <%@ page language="java" import="java.sql.*" %><jsp:useBean id="workM" scope="page" class="webmail.conn"/>
    <%!
       public String getStr(String str)
       {
         try{
     
              String temp_p=str;
              byte[] temp_t=temp_p.getBytes("ISO8859-1");
              String temp=new String(temp_t);
              return temp;
            }
        catch(Exception e)
        {
          e.printStackTrace();
        }
        return null;   
       }
    %>
       <%!
         String logname,e_mail;
         boolean loginAttempt=false;
         String errorMessage="";
       %>
       <% 
          if(request.getParameterValues("findpass")!=null&&request.getParameterValues("logname")!=null&&request.getParameterValues("email")!=null)
           {
             loginAttempt=true;
            }
          if(loginAttempt)
           { 
              logname=request.getParameter("logname");
              e_mail=request.getParameter("email");
              logname=getStr(logname);
              e_mail=getStr(e_mail);
            }
           String sql="select * from member where logname='"+logname+"' and email='"+e_mail+"'";
           ResultSet RS=workM.executeQuery(sql);
           int count=0;
           try{
             while(RS.next())
              { 
                     count++;
                 errorMessage=RS.getString("password");
               }
                 }
              catch(Exception e){
                   e.printStackTrace();
             }
       //如果输入的用户名与emial 对应的话,则出现提示信息
         if(count!=0)
          {
             errorMessage=RS.getString("password");
          }
          else{
               errorMessage="你输入的用户名和email不正确";
            }
          %>
            <table>
              <tr>
               <td align="center">
                <font color=red>您的密码:<%=errorMessage%></font></td>
              </tr>
            </table>
      

  2.   

    RS在while结束后就循环完了,就没用了,你再调用RS.getString("password")就会出错吧
      

  3.   

    可能是你的数据库连接池url没有添加上SelectMethod=Cursor吧
      

  4.   

    unrealwalker(QQ95634620   
    说的没错    就是那原因  
    昨天我对if语句的执行体  设为空 就可以了 
    谢谢大家