register.java

来自「一个很有用的电子刊物发布系统」· Java 代码 · 共 106 行

JAVA
106
字号
package com.am;

import java.util.*;
import java.sql.*;
import java.text.*;
import com.am.user;
public class register extends user
{
    private String strSql;
    private Connection dbConn;
    private int errNum;
    private String errDesc;
    private SimpleDateFormat dateFormatter;
    public register()
    {

        super();
   		strSql="";       
        errNum=0;
        errDesc="";


   }
   
   public void  setConnection(Connection dbConn)
   {
   		this.dbConn=dbConn;
        super.setConnection(dbConn);
   }
   public boolean isExist()
   {
        strSql="select * from `users` ";
		strSql=strSql + " where userName='" + this.userName + "'";
        try
        {
  			Statement stmt=dbConn.createStatement();
 			ResultSet rs =stmt.executeQuery(strSql);
            if(rs.next())
            {
                
                this.ID=rs.getLong("ID");
                this.errNum=0;
                this.errDesc="" ;
                return true;
            }
            else
            {
                this.errNum=-1;
                this.errDesc="the userID hasn't existed!!";
                return false;

            }

		}
		catch(Exception ex)
		{
            this.errNum=-1;
            this.errDesc=ex.toString();
            return true;

		}
        finally
        {
        }
   }
   
  
    public void addUser()
    {
        super.setConnection(this.dbConn);
        super.add();
        this.errNum=super.getErrNum() ;
        this.errDesc=super.getErrDesc() ;
    }

  
    public void modifyUserInfo()
    {
        super.setConnection(this.dbConn);
        super.update();
        this.errNum=super.getErrNum() ;
        this.errDesc=super.getErrDesc() ;
    }
    
    public void modifyUserPassword()
    {
        super.setConnection(this.dbConn);
        super.update();
        this.errNum=super.getErrNum() ;
        this.errDesc=super.getErrDesc() ;
    } 
      
   
    public int getErrNum()
    {
        return errNum;

    }
    
    
    public String getErrDesc()
    {
        return errDesc;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?