---Adminitartordao of students ' course selection system

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.