日期:2014-05-18  浏览次数:20637 次

关于rs.next()和sql的一个怪问题(对我啦)
首先我用的是一个user的bean,其中有一个校验的函数:
      public   boolean   isValidUser(String   webUserName,String   webUserPsw)
      {
        strSql= "select   *   from   `user`   ";
        strSql=strSql   +   "   where   userName= ' "   +   webUserName   +   " ' ";
        strSql=strSql   +   "     and   userPsw= ' "+   webUserPsw   +   " ' ";  
                try
                {
      ResultSet   rs   =   super.exeSqlQuery(strSql);    
                        if   (rs.next())
                        {return   true;         }
                        else{   return   false;   }
}catch(Exception   ex)
{
                        return   false;
}
                finally   {     }       }
使用master的用户登录运行到rs.next()发生错误返回的sql语句如下:
select   *   from   `user`   where   userName= 'master '   and   userPsw= '123 '
而这个语句在mysql中运行是可以查到结果的。
而使用admin的用户登录,则能运行通过,它的sql语句和上面的都是一样的:
select   *   from   `user`   where   userName= 'admin '   and   userPsw= '123 '

二者之间的唯一区别是master是通过在mysql中insert的,而admin则是通过web注册的,但它们之间的sql语法也是一样的啊???
郁闷!


------解决方案--------------------
错误提示呢,
------解决方案--------------------
你的是什么数据库呢!!
检查一下
你程序插入的数据库的数据
特别是密码,可能是经过加密的!
而你手工加入的,是没有加密的!!
比较一下就只了!!!!
------解决方案--------------------
既然这样你就把master用户删除掉,再从WEB上注册master试试