<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 89, comments - 241, trackbacks - 0, articles - 1
       :: 首頁 ::  :: 聯系 :: 聚合  :: 管理

    學生管理系統 源代碼

    Posted on 2009-06-08 09:13 saobaolu 閱讀(1233) 評論(1)  編輯  收藏 所屬分類: java基礎與算法
    http://www.tkk7.com/chenglu/archive/2009/06/08/Student_Manager.html
    DB.java
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package opera.DB;
    import java.sql.*;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    /**
    *
    *
    @author soft
    */
    public class DB {
       
    private String sName;
       
    private String Sno;
       
    private String Sgrade;
       
    private String Ssex;
       
    private String QSql;
       
    private Statement stm=null;
       
    private ResultSet rs = null;
       
    private int i =0;
       
    private String ex;
       
    private String usn;
       
    private String pwd;
       
       
    public Connection getCon(){
         
    Connection con=null;
         
    try {
           
    Class.forName("com.mysql.jdbc.Driver");
             con = DriverManager.getConnection
    ("jdbc:mysql://localhost:3306/stu","root","");
         
    } catch (SQLException ex) {
           
    ex.printStackTrace();
         
    } catch (ClassNotFoundException ex) {
           
    ex.printStackTrace();
         
    }
         
    return con;
       
    }
       
    /**
         *
    @return the sName
         */
       
    public String getSName() {
           
    return sName;
       
    }

       
    /**
         *
    @param sName the sName to set
         */
       
    public void setSName(String sName) {
           
    this.sName = sName;
       
    }

       
    /**
         *
    @return the Sno
         */
       
    public String getSno() {
           
    return Sno;
       
    }

       
    /**
         *
    @param Sno the Sno to set
         */
       
    public void setSno(String Sno) {
           
    this.Sno = Sno;
       
    }

       
    /**
         *
    @return the Sgrade
         */
       
    public String getSgrade() {
           
    return Sgrade;
       
    }

       
    /**
         *
    @param Sgrade the Sgrade to set
         */
       
    public void setSgrade(String Sgrade) {
           
    this.Sgrade = Sgrade;
       
    }
       
    /**
         *
    @return the Ssex
         */
           
    public String getSsex() {
           
    return Ssex;
       
    }

       
    /**
         *
    @param Ssex the Ssex to set
         */
       
    public void setSsex(String Ssex) {
           
    this.Ssex = Ssex;
       
    }


       
    public int DBinsert(int choice) throws SQLException{
           
    //Connection con =null;

                //Class.forName("com.mysql.jdbc.Driver");
                //con = DriverManager.getConnection("jdbc:mysql://localhost:3306/stu","root","");
               
    stm = getCon().createStatement();
               
    if(choice==1){
               
    i = stm.executeUpdate("insert into stu values('"+getSno()+"','"+getSName()+"','"+getSsex()+"','"+getSgrade()+"')");
               
    }
               
    else if(choice==2){
               
    i = stm.executeUpdate("insert into user values('"+getUsn()+"','"+getPwd()+"')");
               
    }//關閉
               
    getCon().close();
                stm.close
    ();
               stm =
    null;
           
    return i;
       
    }
       
    public void DBQuery(int check) throws SQLException{//throws Exception{
      
          //ResultSet rs = null;
          //Statement stm = null;
         
    stm = getCon().createStatement();
          rs = stm.executeQuery
    (getQSql());
         
    //select * from stu where sno = getSno()getQSql()
         
    if(check==1){
           
    //獲取
         
    while(rs.next()){
         
    setSno(rs.getString("sno"));
          setSName
    (rs.getString("sName"));
          setSsex
    (rs.getString("ssex"));
          setSgrade
    (rs.getString("sGrade"));
         
    }
         
    /*關閉
          getCon().close();
            stm.close();
            stm = null;
          rs.close();
          rs = null;
    */         
         
    }
         
    else if(check==2){
           
    while(rs.next()){
           
    setPwd(rs.getString("pwd"));
            setUsn
    (rs.getString("usn"));
         
    }
          }
        }
       
       
    public int DBUpdate(){
       
         
    try {
         
    //Statement stm = null;
         
    stm = getCon().createStatement();
          String sq =
    "update stu set sName = '"+getSName()+"',ssex = '"+getSsex()+"',sGrade = '"+getSgrade()+"'where sno ='"+getSno()+"'";
          i = stm.executeUpdate
    (sq);
         
    //UPDATE Store_Information SET Sales = 500 WHERE store_name = "Los Angeles"  AND Date = "Jan-08-1999"
          //關閉
         
    getCon().close();
          stm.close
    ();
          stm =
    null;
       
    } catch (SQLException ex) {
         
    Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
       
    }
       
    return i;
       
    }
       
    public int DBdelete(){
       
    //Statement stm = null;
       
    try {
         
    getCon().createStatement();
          String dsql=
    "DELETE FROM stu WHERE sno = '"+getSno()+"'";
         
    //DELETE FROM Store_Information WHERE store_name = "Los Angeles"
          //娘啊,user里的表忘刪除了……暈……2009.6.4 18:50 銘記!
         
    stm.executeUpdate("delete from user where usn = '"+getSno()+"'");
          i = stm.executeUpdate
    (dsql);
         
    //關閉
         
    getCon().close();
          stm.close
    ();
          stm =
    null;
       
    } catch (SQLException ex) {
         
    ex.printStackTrace();
       
    }
       
    return i;
       
    }
     
    /**
       *
    @return the QSql
       */
     
    public String getQSql() {
       
    return QSql;
     
    }

     
    /**
       *
    @param QSql the QSql to set
       */
     
    public void setQSql(String QSql) {
       
    this.QSql = QSql;
     
    }

     
    /**
       *
    @return the usn
       */
     
    public String getUsn() {
       
    return usn;
     
    }

     
    /**
       *
    @param usn the usn to set
       */
     
    public void setUsn(String usn) {
       
    this.usn = usn;
     
    }

     
    /**
       *
    @return the pwd
       */
     
    public String getPwd() {
       
    return pwd;
     
    }

     
    /**
       *
    @param pwd the pwd to set
       */
     
    public void setPwd(String pwd) {
       
    this.pwd = pwd;
     
    }
    }

    完整NetBeans項目代碼:
    /Files/chenglu/Student_NetBeana_Src.zip


    沒有所謂的命運,只有不同的選擇!
    主站蜘蛛池模板: 精品国产无限资源免费观看| 亚洲人6666成人观看| 真正全免费视频a毛片| 日本精品人妻无码免费大全| 亚洲男人天堂2017| 一级毛片不卡片免费观看| 亚洲国产精品福利片在线观看| a在线视频免费观看| 国产V亚洲V天堂A无码| 全部免费毛片在线播放| 亚洲国产精品成人精品软件| 国产v精品成人免费视频400条| 亚洲第一男人天堂| 免费国产一级特黄久久| eeuss影院ss奇兵免费com| 亚洲午夜福利717| 99久久99热精品免费观看国产| 337p日本欧洲亚洲大胆艺术| 久久久久国产精品免费免费搜索| 久久亚洲最大成人网4438| 日韩a在线观看免费观看| 一级特黄色毛片免费看| 国产av无码专区亚洲av桃花庵| 18级成人毛片免费观看| 亚洲国产成人综合精品| 亚洲女同成人AⅤ人片在线观看 | 国产91久久久久久久免费| 免费精品视频在线| 久久精品国产亚洲av麻| 日韩毛片免费无码无毒视频观看| 美女被免费网站在线视频免费| 亚洲一区无码中文字幕| av无码国产在线看免费网站| 国产天堂亚洲国产碰碰| 亚洲av无码无在线观看红杏| 成人免费毛片内射美女APP| 一进一出60分钟免费视频| 亚洲第一视频网站| 国产精品免费视频一区| 成人爽a毛片免费| 日韩欧美亚洲中文乱码|