rs.last();
int count = rs.getRow();
if(count > 0)
{
   out.println("用户名已经存在!");
}

解决方案 »

  1.   

    还是不行,但还没有返回错误代码,我是用 catch(Exception e)捕捉错误代码的。
      

  2.   

    问题可能出在你的username变量上。
      

  3.   

    sqlstring="SELECT username FROM USER WHERE username='"+username+"' order by id desc";
    你这sql有问题吧!?如果username唯一的,那可不就一条纪录,rs.next(),肯定就抱错了
      

  4.   

    把捕捉到的错误用打出来吗!e.getMessage();