java学籍管理系统部分代码_学生学籍管理系统(jsp+javabeans) 第五部分

基础类部分代码:

/*

* DataBase.java

*

* Created on 2006年6月15日, 下午1:00

*/

package personadmin;

import java.beans.*;

import java.io.Serializable;

import java.sql.*;

/**

* @author ibm

*/

public class DataBase extends Object implements Serializable

{

//by terry

public Connection con;

public java.sql.Statement sql;

public ResultSet rs=null;

public String sqlStr;

public DataBase()

{

this.connect();

this.sqlStr = "";

}

public boolean connect()

{

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}

catch(ClassNotFoundException e){}

try

{

con = DriverManager.getConnection("jdbc:odbc:stuinfo","","");

sql = con.createStatement();

}

catch (SQLException ex)

{

return false;

}

return true;

}

}

/*

* ChineseProcess.java

*

* Created on 2006年6月16日, 下午10:54

*/

package personadmin;

import java.beans.*;

import java.io.Serializable;

/**

* @author ibm

*/

public class ChineseProcess extends Object implements Serializable

{

/*    private String older;

public ChineseProcess()

{

this.older = "";

}

public void setolder(String temp)

{

this.older = temp;

}*/

public String formatchange(String temp)throws Exception

{

byte b[] = temp.getBytes("ISO-8859-1");

String fuck = new String(b);

//     temp = new String(b);

return fuck;

}

}

/*

* ChangePassword.java

*

* Created on 2006年6月15日, 下午8:07

*/

package personadmin;

import java.beans.*;import java.io.Serializable;import personadmin.DataBase;import java.sql.*;/** * @author ibm */public class ChangePassword extends Object implements Serializable {    private String name;              //用户名    private String type;              //用户类型    private String oldpassword;       //旧密码    private String newpassword;       //新密码    private String affirmpassword;    //确认密码    private DataBase db;              //数据库处理    public ChangePassword()    {        this.name = "";        this.type = "";        this.oldpassword = "";        this.newpassword = "";        this.affirmpassword = "";        this.db = new DataBase();    }    public void setName(String temp)    {        this.name = temp;    }    public void setType(String temp)    {        this.type = temp;    }    public void setoldpassword(String temp)    {        this.oldpassword = temp;    }    public void setnewpassword(String temp)    {        this.newpassword = temp;    }    public void setaffirmpassword(String temp)    {        this.affirmpassword = temp;     }    public String getName()    {        return this.name;    }    public String getType()    {        return this.type;    }    public String getoldpassword()    {        return this.oldpassword;    }    public String getnewpassword()    {        return this.newpassword;    }    public String getaffirmpassword()    {        return this.affirmpassword;    }    public boolean justicenew()         //判断两个密码是否相等    {        return this.newpassword.equals(this.affirmpassword);    }    public boolean justiceolder(String session_password)      //判断旧密码是否输入是否正确    {        //temp从session获得        return this.oldpassword.equals(session_password);    }    //temp用户旧密码    public boolean findOlder(String session_password)  //获得修改密码    {        if (this.justicenew() && this.justiceolder(session_password)) //如果两个密码相等,并且旧密码也是正确的        {            if (this.type.equals("administrator"))                //管理员身份            {                 this.db.sqlStr = "update admininfo set adm_password = '"+this.newpassword+"' where adm_name = '"+this.name+"'";            }            else if (this.type.equals("teacher"))                //老师身份            {                 this.db.sqlStr = "update teacher_name set teacher_password = '"+this.newpassword+"' where teacher_name = '"+this.name+"'";            }            else if (this.type.equals("student"))                //学生身份            {                 this.db.sqlStr = "update registerinfo set reg_password = '"+this.newpassword+"' where reg_name = '"+this.name+"'";            }            return true;         //更改成功        }        else     //输入密码有问题        {            return false;        }    }       public boolean execute(String session_password)throws Exception    {        boolean flag = false;        if (this.findOlder(session_password))                 //如果输入正确        {            flag = true;            try            {                this.db.sql.executeUpdate(this.db.sqlStr);   //修改密码                this.db.sql.close();                           //关闭数据源            }            catch(SQLException e){}                    }        return flag;    }}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值