Student Information Operations:
Package Com.csms.dao;import Java.sql.connection;import Java.sql.preparedstatement;import java.sql.ResultSet;import Java.sql.sqlexception;import java.sql.statement;import com.csms.dblink;import com.csms.entity.Adminitartor;/** * @ Author Li Pei * * @version v1 * * @time 2016/12/2 18:43 * * @program Administrator information to operate the database class * */public class Adminitartordao {//Tube Manager Login Confirm Public Boolean loginconfirm (string name, string password) {//Instantiate Administrator object Adminitartor admin = new Adminitartor ();//1. Received Database Connection object Connection conn = Dblink.getconn ();//2. Query the SQL statement of the administrator string sql = "Select loginname,loginpsd from Adminitrator"; Statement stm = null; ResultSet rs = null;try {//3. Send SQL statement, execute query stm = conn.createstatement (); rs = stm.executequery (sql); while (Rs.next ()) {ADM In.setloginname (rs.getstring ("LoginName")); ADMIN.SETLOGINPSD (rs.getstring ("LOGINPSD")); if (Name.equals ( Admin.getloginname ()) && password.equals (ADMIN.GETLOGINPSD ())) {return true;}} Rs.close ();} catch (Exception e) {e.printstacktrace ();} finally {//4. The operation is complete, release the connectionNext to try {if (STM! = null) Stm.close (),} catch (SQLException e) {//TODO auto-generated catch Blocke.printstacktrace ();}} return false;} Get all of the administrator's identity information public adminitartor getinformation (string userName, String userpsd) {Adminitartor admin = null; Connection conn = Dblink.getconn (); String sql = "Select admiid,adminame,admiage,admigender,admiphone,admiaddress from Adminitrator WHERE loginname=?" and loginpsd=? "; PreparedStatement PTM = null; ResultSet rs = NULL;TRY{PTM = conn.preparestatement (sql);p tm.setstring (1, userName);p tm.setstring (2, USERPSD); rs = Ptm.executequery (); while (Rs.next ()) {admin = new adminitartor (); Admin.setadminid (rs.getstring ("admiid")); Admin.setadminname (rs.getstring ("Adminame")); Admin.setadminage (Rs.getint ("Admiage")); Admin.setadmingender ( Rs.getstring ("Admigender")), Admin.setadminphone (rs.getstring ("Admiphone")), Admin.setadminaddress (Rs.getString ( "Admiaddress"));} Rs.close ();} catch (SQLException e) {e.printstacktrace ();} Finally{try{if (ptm!=null) {ptm.close ();}} catch (SQLExceptione) {e.printstacktrace ();}} return admin;}}
---Adminitartordao of students ' course selection system