当前位置: 网站首页 > WEB > jsp

在jsp中用bean和servlet联合实现用户注册、登录

时间:1970-1-1 08:33:31来源: jsp作者:admin 点击:6次 字体 [ С]
   if(userDBConn.rs_next())
   {
    System.out.println("用户名已存在,请选择其它的用户名!");
    return false;
   }else
    return true;
  }catch(Exception e){
   System.out.println(e.toString());
   return false;
   }
 }
 
 public int getNewID()
 {
  try{
   DBConn newIDDBConn = new DBConn();
   newIDDBConn.executeQuery("select * from tbl_user order by id desc limit 1");
   if(newIDDBConn.rs_next())
   {
    this.newID = newIDDBConn.rs_getInt("id") + 1;
    System.out.println(this.newID);
   }else{
    this.newID = 1;
   }
   return this.newID;
  }catch(Exception e){
   System.out.println(e.toString());
   return -1;
   }   
 }
 
 public int getID()
 {
  return this.newID;
 }
 
 public boolean register(String username,String password,String confirm,String email)
 {
  try{
   DBConn regDBConn = new DBConn();
   String strSQL = "insert into tbl_user(id,name,pwd,email) values('" + this.newID +"','" + username + "','" + password + "','" + email + "')";
   regDBConn.execute(strSQL);
   return true;
  }catch(Exception e){
发表评论
验证码:
最新评论
相关文章
最热文章