Student's School Management System (JSP + Javabeans) Part 5

xiaoxiao2021-04-08  434

Basic class part code:

/ * * Database.java * * Created on June 15, 2006, 1:00 pm * /

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 June 16, 2006, 10:54 pm * /

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 June 15, 2006, 8:07 pm * /

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; // User name private String type; // user type private String oldpassword; // old password private String newpassword; // new password private String affirmpassword; // confirm password private dataBase db; // database processing public ChangePassword () {this.name = ""; This.type = ""; 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 (s tring 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 () // determines whether the two passwords are equal {return this.newpassword.equals (this.affirmpassword);

} Public boolean justiceolder (String session_password) // determines whether the input the old password is correct {// temp obtained return this.oldpassword.equals (session_password) from session;} // temp old password the user public boolean findOlder (String session_password) // Get the change password {if (this.justicnew () && this.justiceold) // If the two passwords are equal, and the old password is also correct {if (this.Type.equals ("administrator")) // Management Identity {this.db.sqlstr = "Update admininfo set adm_password = '" this.newpassword "' where adm_name = '" this.Name "'";} else if (this.type.equals ("teacher") ) // teacher identity {this.db.sqlstr = "Update teacher_name set teacher_password = '" this.newpassword "' where teacher_name = '" this.name "'";} else if (this.Type.equals " ")") // Student identity {this.db.sqlstr = "Update registerinfo set reg_password = '" this.newpassword "' WHER e reg_name = '" this.name "' ";} return true; // Change success} ELSE // Enter the password There is a problem {RETURN FALSE;}} public boolean execute (String session_password) throws exception {boolean flag = false; IF (this.findolder (session_password)) // If you enter the correct {flag = true; try {this.db.sql.executeUpdate (this.db.sqlstr);

转载请注明原文地址:https://www.9cbs.com/read-132935.html

New Post(0)