<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://m.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


    沒有所謂的命運,只有不同的選擇!
    主站蜘蛛池模板: 亚洲尤码不卡AV麻豆| 亚洲视频在线一区二区| 亚洲制服丝袜在线播放| 三年片在线观看免费观看大全一 | 69国产精品视频免费| 亚洲黄色网站视频| 在线观看www日本免费网站| 亚洲国产女人aaa毛片在线| 99视频有精品视频免费观看| 激情内射亚洲一区二区三区| 日韩插啊免费视频在线观看| 久久亚洲精品无码VA大香大香| 亚洲视频在线免费播放| 亚洲人成网亚洲欧洲无码| 国产一级淫片免费播放| igao激情在线视频免费| 久久精品国产亚洲AV麻豆王友容 | 久久精品成人免费观看97| 在线日韩日本国产亚洲| 无码少妇精品一区二区免费动态| 亚洲老熟女@TubeumTV| 大学生一级特黄的免费大片视频 | 黄页免费视频播放在线播放| 亚洲精品麻豆av| 日韩免费高清大片在线| 亚洲国产精品成人午夜在线观看| www国产亚洲精品久久久| 久久er国产精品免费观看2| 亚洲成aⅴ人片在线观| 日韩在线免费电影| 中文字幕在线免费看| 亚洲精品在线免费观看视频| 国产精品jizz在线观看免费 | 99re免费视频| 亚洲精品无码专区久久| 在线精品亚洲一区二区小说| 亚洲美女视频免费| 午夜不卡AV免费| 亚洲av产在线精品亚洲第一站| 一级毛片直播亚洲| 国产大片免费网站不卡美女|