java jlabe_JAVA_连接sqlserver_学生成绩管理系统

《JAVA_连接sqlserver_学生成绩管理系统》由会员分享,可在线阅读,更多相关《JAVA_连接sqlserver_学生成绩管理系统(40页珍藏版)》请在人人文库网上搜索。

1、学生成绩管理系统课程设计实验报告题目学生成绩管理系统学院专业班级同组成员编写日期word范文一、课程设计目的做这个小的学生成绩管理系统来加深对 JAVA所学知识的巩固,以及学习 JAVA与数据库的连接和JAVA的GUI图形界面。二、需求分析此系统实现如下系统功能:(1)使得学生的成绩管理工作更加清晰、条理化、自动化。(2)通过用户名和密码登录系统,查询学生基本资料,学生所学课程成绩, 等功能。容易地完成学生信息的查询操作。(3)设计人机友好界面,功能安排合理,操作使用方便,并且进一步考虑系 统在安全性,完整性,并发控制,备份和恢复等方面的功能要求。三、系统模块设计此系统可分为2个模块,教师管理。

2、模块和学生操作模块,期中教师又包括学 生信息输入与学生成绩录入等;学生模块则包括学生成绩查询与学生信息录入查 询操作等。用户登录V.X系统流程图:CollageChar(10)学院四、数据库1、学生表:FieldTypeNullKeyComme ntIDVarchar(IO) PRI用户名(学号)PwdVarchar(1O) 密码NameChar(10)姓名SexChar(10)性别ClassChar(10)班级2、教师表FieldTypeNullKeyComme ntIDVarchar(10)PRI用户名PwdVarchar(1O)密码3、成绩表FieldTypeNullKeyComme n。

3、tSidchar(10)PRI学号计算机网络char(10)课程Linux操作系统char(10)课程计算机专业英语char(10)课程计算机信息技术char(10)课程Java程序设计char(10)课程数据库应用实训char(10)课程高等数学char(10)课程XMLchar(10)课程五、E-R图5ClassIDPwd计算机网络Sexn ame/Linux操作系SC统学牛表TS j教师表ClocagePwd计算机系成绩计算机专业英计算机信息技术基础数据库应用实训教程Java程序设计高等数学SID(ID)XML附录:源代码1、用户登录界面import java.awt.*;import 。

4、javax.swi ng.*;import java.awt.eve nt.*;import java.sql.*;public class Systems exte nds JFrame impleme nts Actio nListe nerstatic Systems ss;JPa nel panel = new JPa nel();JLabel labell = new JLabel(输入姓名:);JTextField name = new JTextField();JLabel label2 = new JLabel(密 码:);JPasswordField pwd = new JP。

5、asswordField();JButton Enter = new JButton( 登录);JButton Exit = new JButton( 退出);String url = E:mysqlTM1.jpg;ButtonGroup bgp = new ButtonGroup();JRadioButton stu = new JRadioButton( 学生);JRadioButton tch = new JRadioButton( 教师 );public Systems()super(登录系统);this.setResizable(false);JLabel img = new JLa。

6、bel(new ImageIcon(url);img.setBounds(0,0,500,125);panel.add(img);stu.setBounds(165,210,70,20);bgp.add(stu);bgp.add(tch);tch.setBounds(265,210,70,20);7panel.add(stu);panel.add(tch);Enter.setBounds(150,250,80,20);Exit.setBounds(270,250,80,20);Enter.addActionListener(this);Exit.addActionListener(this);。

7、panel.add(Enter);panel.add(Exit);panel.setLayout(null);this.add(panel);label1.setBounds(135,130,100,25);panel.add(label1);name.setBounds(265,130,100,25);panel.add(name);label2.setBounds(135,165,100,25);panel.add(label2);pwd.setBounds(265,165,100,25);panel.add(pwd);this.setBounds(100,100,500,350);thi。

8、s.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);public void actionPerformed(ActionEvent e)if(e.getSource()=Enter)String username , password;username = name.getText();password = new String(pwd.getPassword();tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch (ClassNotFoundExce。

9、ption ce)JOptionPane.showMessageDialog(ss,ce.getMessage();if(stu.isSelected()tryConnection conDriverManager.getConnection(jdbc:odbc:shujuku,sa,);Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery(select * from STU); while(rs.next()if(rs.getString(ID).equals(username) if(rs.getSt。

10、ring(Pwd).equals(password) JOptionPane.showMessageDialog(ss, 登 陆成功 );Students stu = new Students();elseJOptionPane.showMessageDialog(ss, 登 录失败);rs.close();stmt.close();catch (SQLException se)9JOptionPane.showMessageDialog(ss,se.getMessage();else if(tch.isSelected()tryConnection con = DriverManager.g。

11、etConnection(jdbc:odbc:shujuku,sa,);Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery(select * from TCH);while(rs.next()if(rs.getString(ID).equals(username) if(rs.getString(Pwd).equals(password) JOptionPane.showMessageDialog(ss, 登 陆 成功 );elseJOptionPane.showMessageDialog(ss, 登 。

12、录失败);catch (SQLException se)JOptionPane.showMessageDialog(ss,se.getMessage();elseSystem.exit(0);public static void main(String args)Systems sys = new Systems();#2、学生登录界面: import java.awt.*;import javax.swing.*;import java.awt.event.*;public class Students extends JFrame implements ActionListener JMe。

13、nuBar jmb = new JMenuBar();JMenu Message = new JMenu( 信息 );JMenu Score = new JMenu( 成绩 );JMenuItem Item1 = new JMenuItem( 插入 );JMenuItem Item2 = new JMenuItem( 查询 );JMenuItem Item3 = new JMenuItem( 查询 );public Students()super(学生界面);this.setSize(500,400);this.setVisible(true);this.setResizable(false)。

14、;this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setJMenuBar(jmb);jmb.add(Message);jmb.add(Score);Message.add(Item1);Message.add(Item2);Score.add(Item3);Item1.addActionListener(this);Item2.addActionListener(this);Item3.addActionListener(this);public void actionPerformed(ActionEvent e)if(e.g。

15、etSource()=Item1)AddMsg ad = new AddMsg();else if(e.getSource()=Item2)elseScore so = new Score();public static void main(String args)Students stu = new Students();3、教师登录界面:import java.awt.*;import javax.swing.*;import java.awt.event.*;public class Teachers extends JFrame implements ActionListener JM。

16、enuBar bar = new JMenuBar();JMenu menu1 = new JMenu( 信息 );JMenu menu2 = new JMenu( 成绩 );JMenuItem item1 = new JMenuItem( 录入信息 );15JMenuItem item2 = new JMenuItem( 录入成绩 );JPanel jpl = new JPanel();public Teachers()super(教师界面);this.setSize(500,300);this.setResizable(false);this.setVisible(true);this.s。

17、etDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setJMenuBar(bar);this.add(jpl);jpl.setLayout(null);bar.add(menu1);bar.add(menu2);menu1.add(item1);menu2.add(item2);item1.addActionListener(this);item2.addActionListener(this);public void actionPerformed(ActionEvent e)if(e.getSource()=item1)AddMsg ms。

18、g = new AddMsg();elseAddscore as = new Addscore();public static void main(String args)Teachers tch = new Teachers();4、学生用户添加界面:import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class AddMsg extends JFrame implements ActionListenerstatic AddMsg s;/* 添加学生信息控件 */JP。

19、anel jpl = new JPanel();JLabel labell = new JLabel(添加基本信息JLabel.CENTER);JLabel Iabel2 = new JLabel(学号:,JLabel.CENTER);JLabel label3 = new JLabel(姓名:,JLabel.CENTER);JLabel label4 = new JLabel(性别:,JLabel.CENTER);JLabel label5 = new JLabel(班级:,JLabel.CENTER);JLabel label6 = new JLabel(学院:,JLabel.CENTER。

20、);JTextField num = new JTextField(2);JTextField nam = new JTextField(4);ButtonGroup bgp = new ButtonGroup();JRadioButton man = new JRadioButton( 男);JRadioButton women = new JRadioButton( 女);JTextField clas = new JTextField();JTextField scl = new JTextField();JButton reset = new JButton( 重置 );JButton。

21、 addmsg = new JButton( 添加 );public AddMsg()super(添加学生信息);this.setResizable(false);this.setSize(500,400);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.add(jpl);jpl.setLayout(null);addmsg.addActionListener(this);reset.addActionListener(this);/*插入面板 */label1.setBounds(1。

22、00,20,300,20);jpl.add(label1);label2.setBounds(100,50,70,20);jpl.add(label2);num.setBounds(190,50,140,20);jpl.add(num);label3.setBounds(100,90,70,20);jpl.add(label3);nam.setBounds(190,90,140,20); jpl.add(nam); label4.setBounds(100,130,70,20);jpl.add(label4);man.setBounds(190,130,60,20);women.setBoun。

23、ds(270,130,60,20);jpl.add(man);jpl.add(women);bgp.add(man);bgp.add(women);label5.setBounds(100,170,70,20);jpl.add(label5);clas.setBounds(190,170,140,20);jpl.add(clas);label6.setBounds(100,210,70,20);jpl.add(label6);scl.setBounds(190,210,140,20);jpl.add(scl);reset.setBounds(120,250,90,20);addmsg.setB。

24、ounds(240,250,90,20);jpl.add(reset);jpl.add(addmsg);19public void actionPerformed(ActionEvent e)if(e.getSource()=addmsg)String sex;if(man.isSelected()sex=男;elsesex=女;tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(s,ce.getMessage();tryCon。

25、nection con = DriverManager.getConnection(jdbc:odbc:shujuku,sa,);Statement stmt = con.createStatement();String str = insert into STU(ID , Pwd , Name , Sex , Class , Collage)values(+num.getText()+,+123,+nam.getText()+,+sex+,+clas. getText()+,+scl.getText()+);/ int a = stmt.executeUpdate(insert into S。

26、TU(ID , Pwd , Name , Sex , Class , Collage)values(+num.getText()+,+12345678,+nam.getText()+,+sex+, +clas.getText()+,+scl.getText()+);System.out.println(str);int a = stmt.executeUpdate(str);if(a=1)JOptionPane.showMessageDialog(s, 已成功添加 );elseJOptionPane.showMessageDialog(s, 添加失败 );stmt.close();#catch。

27、 (SQLException se)JOptionPane.showMessageDialog(s,se.getMessage();elsenum.setText();nam.setText();clas.setText();scl.setText();num.requestFocus();public static void main(String args)AddMsg amg = new AddMsg();5、学生成绩添加: import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;p。

28、ublic class Addscore extends JFrame implements ActionListenerstatic Addscore ss;JLabel label = new JLabel(学号:”),new JLabel(计算机网络:”),new JLabefLi nux 操作系统:”),n ew JLabel(计算机专业英语:”),new JLabel(计算 机信息技术基础:),new JLabel(Java程序设计:),new JLabel(数据库应用实 训教程:),new JLabel(高等数学:),new JLabel(XML: );JTextField txt。

29、 = new JTextField() , new JTextField() , new JTextField() , new JTextField() , new JTextField() ,new JTextField() , new JTextField() ,new JTextField() ,new JTextField() ;JButton add = new JButton( 添加);JButton reset = new JButton( 重置);JPanel jpl = new JPanel();JLabel title = new JLabel( 添加学生成绩 , JLab。

30、el.CENTER);Font f = new Font( 黑体 , Font.BOLD , 16 );int s = 100;public Addscore()super(添加学生信息);this.setResizable(false);CLOSE);this.setSize(500,600); this.setDefaultCloseOperation(EXIT_ON this.setVisible(true);this.add(jpl);add.addActionListener(this);reset.addActionListener(this);jpl.setLayout(null。

31、);title.setBounds(150,40,200,20);title.setFont(f);title.setForeground(Color.red);jpl.setBackground(Color.LIGHT_GRAY);jpl.add(title);for(int i = 0 ; i label.length ; i+)labeli.setBounds(100,s,140,20);jpl.add(labeli);txti.setBounds(260,s,140,20); jpl.add(txti);s=s+40;add.setBounds(150,s,80,20);reset.s。

32、etBounds(250,s,80,20);jpl.add(add);jpl.add(reset);public void actionPerformed(ActionEvent e)if(e.getSource()=add)tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(ss,ce.getMessage();tryconConnectionDriverManager.getConnection(jdbc:odbc:shuj。

33、uku,sa,);Statement stmt = con.createStatement();int a = stmt.executeUpdate(insert into 计算机系成绩 (SID , 计 算机网络 , Linux 操作系统 , 计算机专业英语 , 计算机信息技术基础 , Java 程 序 设 计 , 数 据 库 应 用 实 训 教 程 , 高 等 数 学 , Xml)values(+txt0.getText()+,+txt1.getText()+,+txt2.getText()+,+txt 3.getText()+,+txt4.getText()+,+txt5.getText。

34、()+,+txt6.getText()+,+t xt7.getText()+,+txt8.getText()+);if(a=1)JOptionPane.showMessageDialog(ss, 添加成功 );elseJOptionPane.showMessageDialog(ss, 添加失败 );catch (SQLException se)JOptionPane.showMessageDialog(ss,se.getMessage();elsefor(int i = 0 ; itxt.length ; i+) txti.setText(); txt0.requestFocus();publ。

35、ic static void main(String args)Addscore as = new Addscore();6、学生信息查询:import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class Serch extends JFrame implements ActionListener/* 查询学生信息控件 */static Serch s;JPanel jpl = new JPanel();JLabel SCH = new JLabel(喳询学生信息JLabe。

36、l.CENTER);JLabel labell = new JLabel(请输入学号:,JLabel.CENTER);JButton serch = new JButton( 喳询 );JLabel label2 = new JLabel(姓名:,JLabel.CENTER);JLabel label3 = new JLabel(班级:,JLabel.CENTER);JLabel label4 = new JLabel(学校:,JLabel.CENTER);JLabel label5 = new JLabel(性别:,JLabel.CENTER);ButtonGroup bgp = new B。

37、uttonGroup();JRadioButton man = new JRadioButton( 男);JRadioButton women = new JRadioButton( 女);JTextField num = new JTextField();JTextField nam = new JTextField();JTextField clas = new JTextField();JTextField scl = new JTextField();JButton reset = new JButton( 重置 );public Serch()this.setSize(500,400。

38、);this.setVisible(true);this.setResizable(false);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.add(jpl);jpl.setLayout(null);serch.addActionListener(this);reset.addActionListener(this);/*查询面板 */SCH.setBounds(100,20,300,20);jpl.add(SCH);label1.setBounds(100,60,100,20);jpl.add(label1);num.se。

39、tBounds(220,60,140,20);jpl.add(num);serch.setBounds(120,100,90,20);reset.setBounds(260,100,90,20);jpl.add(serch);jpl.add(reset);label2.setBounds(100,140,70,20);jpl.add(label2);nam.setBounds(190,140,140,20);jpl.add(nam);label5.setBounds(100,180,70,20);jpl.add(label5);man.setBounds(205,180,60,20);wome。

40、n.setBounds(285,180,60,20);bgp.add(man);bgp.add(women);jpl.add(man);jpl.add(women);label3.setBounds(100,220,70,20);jpl.add(label3);clas.setBounds(190,220,140,20);jpl.add(clas);label4.setBounds(100,260,70,20);jpl.add(label4);scl.setBounds(190,260,140,20);jpl.add(scl);public void actionPerformed(Actio。

41、nEvent e)String id = num.getText();if(e.getSource()=serch)tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(s,ce.getMessage();tryConnection con DriverManager.getConnection(jdbc:odbc:shujuku,sa,);Statement stmt = con.createStatement();Result。

42、Set rs = stmt.executeQuery(select * from STU where ID = + id + );while(rs.next()nam.setText(rs.getString(Name);if(rs.getStri ng(Sex).equals(男)man.setSelected(true);elsewomen.setSelected(true);clas.setText(rs.getString(Class); scl.setText(rs.getString(Collage);catch (SQLException se)JOptionPane.showM。

43、essageDialog(s,se.getMessage();public static void main(String args)Serch sch = new Serch();7、学生成绩查询import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.awt.font.*;import java.sql.*;public class Score extends JFrame implements ActionListenerstatic Score s;JLabel title = new JLab。

44、el( 查询成绩 ,JLabel.CENTER);Font f = new Font( 楷体 ,Font.BOLD+Font.ITALIC,16);JPanel jpl = new JPanel();JLabel labell = new JLabel(请输入学号:JLabel.CENTER);JTextField num = new JTextField();JButton serch = new JButton( 查询成绩 );JButton reset = new JButton( 重置 );JLabel label2 = new JLabel(计算机网络:,JLabel.LEFT);J。

45、Label label3 = new JLabel(Linux 操作系统: ,JLabel.LEFT);JLabel Iabel4 = new JLabel(计算机专业英语:JLabel.LEFT);JLabel Iabel5 = new JLabel(计算机信息技术基础:,JLabel.LEFT);JLabel label6 = new JLabel(Java 程序设计:,JLabel.LEFT);JLabel label7 = new JLabel(数据库:,JLabel.LEFT);JLabel label8 = new JLabel(高等数学:,JLabel.LEFT);JLabel 。

46、label9 = new JLabel(XML: ,JLabel.LEFT);JTextField txt = new JTextField() , new JTextField() , new JTextField() , new JTextField() , new JTextField() , new JTextField() ,new JTextField() , new JTextField();static int p = 140;public Score()super(”查询分数);this.setResizable(false);this.setSize(500,550);th。

47、is.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);title.setFont(f);this.add(jpl);jpl.setLayout(null);33title.setBounds(100,20,300,20);jpl.add(title);label1.setBounds(100,60,90,20);jpl.add(label1);num.setBounds(210,60,140,20);jpl.add(num);serch.setBounds(130,100,90,20);reset.set。

48、Bounds(240,100,90,20);jpl.add(serch);jpl.add(reset);serch.addActionListener(this);reset.addActionListener(this);label2.setBounds(100,140,140,20);label3.setBounds(100,180,140,20);label4.setBounds(100,220,140,20);label5.setBounds(100,260,140,20);label6.setBounds(100,300,140,20);label7.setBounds(100,34。

49、0,140,20);label8.setBounds(100,380,140,20);jpl.add(label2);jpl.add(label3);jpl.add(label4);jpl.add(label5);jpl.add(label6);jpl.add(label7);jpl.add(label8);jpl.add(label9);for(int i = 0 ;itxt.length ; i+)txti.setBounds(260,p,140,20);jpl.add(txti);p=p+40;public void actionPerformed(ActionEvent e) if(e。

50、.getSource()=serch)String id = num.getText();tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);catch (ClassNotFoundException ce)JOptionPane.showMessageDialog(s,ce.getMessage();try Connection con = DriverManager.getConnection(jdbc:odbc:shujuku,sa,);Statement stmt = con.createStatement();ResultSet rs = s。

51、tmt.executeQuery(select 计算机系成绩 .* from STU , 计算机系成绩 where STU.ID = + id + AND STU.ID = 计算机系成 绩.SID);while(rs.next()for(int i = 0 ; itxt.length ; i+)txti.setText(rs.getString(i+2);catch (SQLException se)JOptionPane.showMessageDialog(s,se.getMessage();elsefor(int i = 0;itxt.length ; i+)txti.setText(); num.setText();public static void main(String args)Score s = new Score();37。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值