if(rs.next()) { 
  rs.close();
   response.sendRedirect("../error.jsp");
}

解决方案 »

  1.   

    先把数据从客户端取到,然后把这个数据放到sql语句里查询,如果rs.next()说明该用户已经在数据库里了!则提示用户一下,已经存在了!
      

  2.   

    我以前是这样写的,可能不是很好,很久没碰过了~~~String user_name="";
      if(request.getParameter("user_name")!=null)
      user_name=request.getParameter("user_name");
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      Connection con;
      String dbur1 =
              "jdbc:mysql://"
              + "localhost"
              + "/"
              + "asdf"
              + "?user="
              + "root"
              + "&password="
              + ""
              + "&useUnicode=true&characterEncoding=GB2312";
      //con=DriverManager.getConnection("jdbc:mysql://localhost/asdf","root","");
      con = DriverManager.getConnection(dbur1);
      Statement stmt = con.createStatement();  String sql="select user_name from member where user_name = ";
    sql+="'"+user_name+"'";
      //out.println(sql);
      ResultSet rs;
      rs=stmt.executeQuery(sql);
      if(rs.next())
      {
    response.sendRedirect("1step.jsp");//重复名字转回上级页面
      }
      

  3.   

    在你提交到的页面中
    做个 select * from 表 where 用户名='提交的用户名' 查询
    while(结果结.next){
    说明用户存在,跳转到重新注册页面,
    }
    接着写你的注册代码就行了
      

  4.   

    select * from table where id='yourid'
    if(rs.next){
    退出}
    else  注册