【SQL开源代码栏目提醒】:网学会员,鉴于大家对SQL开源代码十分关注,论文会员在此为大家搜集整理了“基于JAVA的学生成绩管理系统源代码 - 编程语言”一文,供大家参考学习!
Java 程序设计 系 专 业 班 级 学 号 15 号 姓 名 刘振基 题 目 学生成绩管理系统任课教师 彭杰 一:要求1、 用到书上(课本或实验册)上的至少三个实例2、 用到至少两种布局和至少四种组件3、 用到对话框4、 用到对数据库的查询、删除、添加和修改5、 最好用到输入输出流6、 具有一定的实际意义 二:内容 本系统用 access 作为数据库,用到了书上的布局实例和数据库连接实例功能: 1、输入十个同学的学号,姓名,出生日期,二科成绩学,大学英语 。
2、输入学号查询学生信息。
3、删除记录 4、查询记录 5、添加记录 6、修改记录 三:
代码 第一部分: public class main public static void mainString args zhuchuangkou winnew zhuchuangkou 第二部分主界面: import java.awt. import java.awt.event. import javax.swing. import javax.swing.border.public class zhuchuangkou extends Frame implements ActionListener Button button1button2button3button4tuichu Panel p1p2p3 Label l1l2l3 TextField a1a2 Box b1b2b3b4b5 ss s zhuchuangkou button1new Buttonquot登陆quot button2new Buttonquot删除quot button3new Buttonquot修改quot button4new Buttonquot添加quot tuichunew Buttonquot退出quot p1new Panel p2new Panel p3new Panel l1new Labelquot学生成绩管理quotLabel.CENTER l1.setFontnew Fontquot宋体quotFont.BOLD72 l1.setBackgroundColor.green l2new Labelquot登录名quot l3new Labelquot密码quot a1new TextField10 a2new TextField10 a2.setEchoChar b1Box.createVerticalBox b1.addl2 b1.addBox.createVerticalStrut8 b1.addl3 b2Box.createVerticalBoxb2.adda1b2.addBox.createVerticalStrut8b2.adda2b4Box.createHorizontalBoxb4.addbutton1b4.addBox.createHorizontalStrut10b4.addtuichub3Box.createHorizontalBoxb3.addb1b3.addBox.createHorizontalStrut10b3.addb2b5Box.createVerticalBoxb5.addb3b5.addBox.createVerticalStrut8b5.addb4button1.addActionListenerthisbutton2.addActionListenerthisbutton3.addActionListenerthisbutton4.addActionListenerthistuichu.addActionListenerthisp1.addl1p2.addb5addp1BorderLayout.NORTHaddp2BorderLayout.CENTERaddp3BorderLayout.PAGE_ENDaddWindowListenernew WindowAdapter public void windowClosingWindowEvent e dispose setBackgroundColor.RED setBounds10 10 1000 500 setVisibletrue validate public void actionPerformedActionEvent e ife.getSourcetuichu System.exit0 ife.getSourcebutton1 ifa1.getText.equalsquotliuzhenjiquotampampa2.getText.equalsquot123456quot new chuankou System.out.printlnquotwwwwwquot dispose else System.out.printquotnishurucuowuquot 第三部分选择操作:import java.awt.import java.awt.event.import javax.swing.import javax.swing.border.public class zhuchuangkou extends Frame implements ActionListener Button button1button2button3button4tuichu Panel p1p2p3 Label l1l2l3TextField a1a2Box b1b2b3b4b5ss szhuchuangkou button1new Buttonquot登陆quot button2new Buttonquot删除quot button3new Buttonquot修改quot button4new Buttonquot添加quot tuichunew Buttonquot退出quot p1new Panel p2new Panel p3new Panel l1new Labelquot学生成绩管理quotLabel.CENTER l1.setFontnew Fontquot宋体quotFont.BOLD72 l1.setBackgroundColor.green l2new Labelquot登录名quot l3new Labelquot密码quot a1new TextField10 a2new TextField10 a2.setEchoChar b1Box.createVerticalBox b1.addl2 b1.addBox.createVerticalStrut8 b1.addl3 b2Box.createVerticalBox b2.adda1 b2.addBox.createVerticalStrut8 b2.adda2 b4Box.createHorizontalBox b4.addbutton1 b4.addBox.createHorizontalStrut10 b4.addtuichu b3Box.createHorizontalBox b3.addb1 b3.addBox.createHorizontalStrut10 b3.addb2 b5Box.createVerticalBox b5.addb3 b5.addBox.createVerticalStrut8 b5.addb4 button1.addActionListenerthis button2.addActionListenerthis button3.addActionListenerthis button4.addActionListenerthis tuichu.addActionListenerthis p1.addl1 p2.addb5 addp1BorderLayout.NORTH addp2BorderLayout.CENTER addp3BorderLayout.PAGE_END addWindowListenernew WindowAdapter public void windowClosingWindowEvent e dispose setBackgroundColor.RED setBounds10 10 1000 500 setVisibletrue validate public void actionPerformedActionEvent e ife.getSourcetuichu System.exit0 ife.getSourcebutton1 ifa1.getText.equalsquotliuzhenjiquotampampa2.getText.equalsquot123456quot new chuankou System.out.printlnquotwwwwwquot dispose else System.out.printquotnishurucuowuquot 第四部分查询界面实现:import java.awt.import java.awt.event.import java.
sql.import javax.swing.JOptionPanepublic class ss extends Frame implements TextListenerActionListener Button xunzhao TextField input TextArea show String s int k Connection con Statement
sql int sum0 ResultSet rs ss Panel pnew Panel xunzhao new Buttonquot查找quot input new TextField10 show new TextArea643 p.addnew Labelquot输入学号quot p.addinput p.addxunzhao xunzhao.addActionListenerthis show.addTextListenerthis show.setEditablefalse addpBorderLayout.NORTH addshowBorderLayout.CENTER setBounds1030500200 setVisibletrue validate addWindowListenernew WindowAdapter public void windowClosingWindowEvent e dispose public void actionPerformedActionEvent ee boolean bootrue sinput.getText kInteger.parseInts try Class.forNamequotsun.jdbc.odbc.JdbcOdbcDriverquot catchClassNotFoundException eee System.out.printlnquotquoteee; try conDriverManager.getConnectionquotjdbc:odbc:sunquotquotgxyquotquot123quot sqlcon.createStatement rssql.executeQueryquotSELECT FROM chengjibiao quot whilers.next int numberrs.getIntquotnumberquot String namers.getStringquotnamequot String daters.getStringquotbirthdayquot int mathrs.getIntquotmathquot int englishrs.getIntquotenglishquot ifnumberk boofalse show.setTextnull show.appendquot学号:quotnumberquot quot 出生:quotdatequot 数学 quotmathquot 英语 quotenglish show.appendquotnquot con.close ifboo JOptionPane.showMessageDialogthis quot你输入的学号不存在quot catchSQLException eee System.out.printlneee 第五部分删除:import java.awt.import java.awt.event.import java.
sql.import javax.swing.JOptionPanepublic class shanchu extends Frame implements TextListenerActionListener Button xunzhao TextField input TextArea show String s int ks1j Connection con Statement
sql int sum0 ResultSet rs shanchu Panel pnew Panel xunzhao new Buttonquot删除quot input new TextField10 show new TextArea643 p.addnew Labelquot输入要删除的quot quot学号quot p.addinput p.addxunzhao xunzhao.addActionListenerthis show.addTextListenerthis show.setEditablefalse addpBorderLayout.NORTH addshowBorderLayout.CENTER setBounds1030500200 setVisibletrue validate addWindowListenernew WindowAdapter public void windowClosingWindowEvent e dispose public void actionPerformedActionEvent ee boolean bootrue sinput.getText kInteger.parseInts String mdir try Class.forNamequotsun.jdbc.odbc.JdbcOdbcDriverquot catchClassNotFoundException eee System.out.printlnquotquoteee try conDriverManager.getConnectionquotjdbc:odbc:sunquotquotgxyquotquot123quot sqlcon.createStatement rssql.executeQueryquotSELECT FROM chengjibiaoquot whilers.next int numberrs.getInt2 String namers.getString3 String daters.getStringquotbirthdayquot int mathrs.getIntquotmathquot int englishrs.getIntquotenglishquot ifnumberk show.setTextquot你删除了:quot show.appendquot学号: quotnumberquot quot 出生:quotdatequot 数学 quotmathquot 英语 quotenglish show.appendquotnquot mquotDELETE FROM chengjibiao WHERE numberquotkquotquot
sql.executeUpdatem con.close catchSQLException e System.out.printlne 第六部分修改: import java.awt. import java.awt.event. import java.
sql. import javax.swing.JOptionPane public class xiugai extends Frame implements TextListenerActionListener Button charu TextField input1input2input3input4input5input6 TextArea show Panel p1p2 int ks1j Connection con Statement
sql int sum0 ResultSet rs xiugai p1new Panel p2new Panel charu new Buttonquot修改quot input1 new TextField10 input2 new TextField10 input3 new TextField10 input4 new TextField10 input5 new TextField10 input6 new TextField10 show new TextArea643 p1.addnew Labelquot请输入要修改的学号quot p1.addnew Labelquotnumberquot p1.addinput1 p2.addnew Labelquot请输入修改的数据quot p2.addnew Labelquotnamequot p2.addinput2 p2.addnew Labelquotdatequot p2.addinput3 p2.addnew Labelquotmathquot p2.addinput4 p2.addnew Labelquotenglishquot p2.addinput5 p2.addcharu charu.addActionListenerthis show.addTextListenerthis show.setEditablefalse addp1BorderLayout.NORTH addp2BorderLayout.CENTER setBounds10301200200 setVisibletrue validate addWindowListenernew WindowAdapter public void windowClosingWindowEvent e dispose public void actionPerformedActionEvent ee boolean bootrue String s0s1s2s3s4s5insert1recodenamedate int m0m1m2m3numbermathenglish s1input1.getText m1Integer.parseInts1 numberm1 s4input4.getText m2Integer.parseInts4 mathm2 s5input5.getText m3Integer.parseInts5 englishm3 try Class.forNamequotsun.jdbc.odbc.JdbcOdbcDriverquot catchClassNotFoundException eee System.out.printlnquotquoteee try conDriverManager.getConnectionquotjdbc:odbc:sunquotquotgxyquotquot123quot sqlcon.createStatement recodequotquotm0quotquotnumberquotquotquotquotnamequotquotquotquotquotquotdatequotquotquotquotmathquotquot englishquotquot insert1quotUPDATE chengjibiao SET mathquotmathquotenglishquotenglishquot WHERE numberquotnumberquotquot
sql.executeUpdateinsert1 catchSQLException e System.out.printlne 第七部分添加:import java.awt.import java.awt.event.import java.
sql.import javax.swing.JOptionPanepublic class charu extends Frame implements TextListenerActionListener Button charu TextField input1input2input3input4input5input6 TextArea show int ks1j Connection con Statement
sql int sum0 ResultSet rs charu Panel pnew Panel charu new Buttonquot插入quot input1 new TextField10 input2 new TextField10 input3 new TextField10 input4 new TextField10 input5 new TextField10 input6 new TextField10 show new TextArea643 p.addnew Labelquot请输入要插入的数据quot p.addnew LabelquotIDquot p.addinput6 p.addnew Labelquotnumberquot p.addinput1 p.addnew Labelquotnamequot p.addinput2 p.addnew Labelquotdatequot p.addinput3 p.addnew Labelquotmathquot p.addinput4 p.addnew Labelquotenglishquot p.addinput5 p.addcharu charu.addActionListenerthis show.addTextListenerthis show.setEditablefalse addpBorderLayout.NORTH addshowBorderLayout.CENTER setBounds10301200200 setVisibletrue validate addWindowListenernew WindowAdapter public void windowClosingWindowEvent e dispose public void actionPerformedActionEvent ee boolean bootrue String s0s1s2s3s4s5insert1recodenamedate int m0m1m2m3numbermathenglish s0input5.getText m0Integer.parseInts0 s1input1.getText m1Integer.parseInts1 numberm1 s2input2.getText names2 s3input3.getText dates3 s4input4.getText m2Integer.parseInts4 mathm2 s5input5.getText m3Integer.parseInts5 englishm3 try Class.forNamequotsun.jdbc.odbc.JdbcOdbcDriverquot catchClassNotFoundException eee System.out.printlnquotquoteee try conDriverManager.getConnectionquotjdbc:odbc:sunquotquotgxyquotquot123quot sqlcon.createStatement recodequotquotm0quotquotnumberquotquotquotquotnamequotquotquotquotquotquotdatequotquotquotquotmathquotquot englishquotquot insert1quotINSERT INTO chengjibiao VALUES quotrecode
sql.executeUpdateinsert1 show.setTextquot你插入了:quot show.appendquot学号:quotnumberquot quot 出生:quotdatequot 数学 quotmathquot 英语 quotenglish show.appendquotnquot catchSQLException e System.out.printlne JOptionPane.showMessageDialogthis quot你输入的不正确quot 四:运行效果 五总结: 本次课程设计,让我获益匪浅,不仅更深入的了解 Java 这门学科,更使自己有了继续探索的兴趣。
于个人而言,在程序设计的过程中,我.
上一篇:
Java_QQ_源程序代码
下一篇:
英文课程作业:电影库(Piddington library )建立方案分析