您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 人事档案/员工关系 > 学生信息管理系统+SQL数据库
本人亲自做的,不需要做任何修改即可顺利运行,sql表也与程序无缝连接,没有未识别部分。Sql表如下:CREATETABLESTU(学号varchar(14)PRIMARYKEY,姓名varchar(8)NOTNULL,密码varchar(8)NOTNULL,班级varchar(14)NOTNULL,性别varchar(2),学校varchar(14)NOTNULL);CREATETABLETCH(用户名varchar(8)NOTNULL,密码varchar(8)NOTNULL);CREATETABLE成绩表(学号varchar(14)PRIMARYKEY,计算机网络varchar(8)NOTNULL,汽车概论varchar(8)NOTNULL,初级日语varchar(8)NOTNULL,接口技术varchar(8)NOTNULL,ava程序设计varchar(8)NOTNULL,数据库varchar(8)NOTNULL,大学物理varchar(8)NOTNULL);源程序代码:importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;importjava.sql.*;publicclasssystemsextendsJFrameimplementsActionListener{staticsystemsss;JPanelpanel=newJPanel();JLabellabel1=newJLabel(输入姓名:);JTextFieldname=newJTextField();JLabellabel2=newJLabel(密码:);JPasswordFieldpwd=newJPasswordField();JButtonEnter=newJButton(登录);JButtonExit=newJButton(退出);Stringurl=D:\\Systems\\title.jpg;ButtonGroupbgp=newButtonGroup();JRadioButtonstu=newJRadioButton(学生);JRadioButtontch=newJRadioButton(教师);publicsystems(){super(登录系统);this.setResizable(false);JLabelimg=newJLabel(newImageIcon(url));img.setBounds(0,0,500,100);panel.add(img);stu.setBounds(165,210,70,20);tch.setBounds(265,210,70,20);bgp.add(stu);bgp.add(tch);panel.add(stu);panel.add(tch);Enter.setBounds(150,250,80,20);Exit.setBounds(270,250,80,20);Enter.addActionListener(this);Exit.addActionListener(this);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);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}publicvoidactionPerformed(ActionEvente){if(e.getSource()==Enter){Stringusername,password;username=name.getText();password=pwd.getText();try{Class.forName(oracle.jdbc.driver.OracleDriver);}catch(ClassNotFoundExceptionce){JOptionPane.showMessageDialog(ss,ce.getMessage());}if(stu.isSelected()){try{Connectioncon=DriverManager.getConnection(jdbc:oracle:thin:@user29:1521:XE,hr,oracle);Statementstmt=con.createStatement();ResultSetrs=stmt.executeQuery(select*fromSTU);while(rs.next()){if((rs.getString(学号).equals(username))&&(rs.getString(密码).equals(password))){JOptionPane.showMessageDialog(ss,登陆成功);Studentsstu=newStudents();}else{JOptionPane.showMessageDialog(ss,登录失败);}}rs.close();stmt.close();}catch(SQLExceptionse){JOptionPane.showMessageDialog(ss,se.getMessage());}}elseif(tch.isSelected()){try{Connectioncon=DriverManager.getConnection(jdbc:oracle:thin:@user29:1521:XE,hr,oracle);Statementstmt=con.createStatement();ResultSetrs=stmt.executeQuery(select*fromTCH);while(rs.next()){if((rs.getString(用户名).equals(username))&&(rs.getString(密码).equals(password))){JOptionPane.showMessageDialog(ss,登陆成功);}else{JOptionPane.showMessageDialog(ss,登录失败);}}}catch(SQLExceptionse){JOptionPane.showMessageDialog(ss,se.getMessage());}}}else{System.exit(0);}}publicstaticvoidmain(String[]args){systemssys=newsystems();}}importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;publicclassStudentsextendsJFrameimplementsActionListener{JMenuBarjmb=newJMenuBar();JMenuMessage=newJMenu(信息);JMenuScore=newJMenu(成绩);JMenuItemItem1=newJMenuItem(插入);JMenuItemItem2=newJMenuItem(查询);JMenuItemItem3=newJMenuItem(查询);publicStudents(){super(学生界面);this.setSize(500,400);this.setVisible(true);this.setResizable(false);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);}publicvoidactionPerformed(ActionEvente){if(e.getSource()==Item1){AddMsgad=newAddMsg();}elseif(e.getSource()==Item2){Serchser=newSerch();}else{}}publicstaticvoidmain(String[]args){Studentsstu=newStudents();}}importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;publicclassTeachersextendsJFrameimplementsActionListener{JMenuBarbar=newJMenuBar();JMenumenu1=newJMenu(信息);JMenumenu2=newJMenu(成绩);JMenuItemitem1=newJMenuItem(录入信息);JMenuItemitem2=newJMenuItem(录入成绩);JPaneljpl=newJPanel();publicTeachers(){super(教师界面);this.setSize(500,300);this.setResizable(false);this.setVisible(true);this.setDefaultCloseOperation(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);}publicvoidactionPerformed(ActionEvente){if(e.getSource()==item1){AddMsgmsg=newAddMsg();}else{Addscoreas=newAddscore();}}publicstaticvoidmain(String[]args){Teacherstch=newTeachers();}}importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;importjava.sql.*;publicclassSerchextendsJFrameimplementsActionListener{/*查询学生信息控件*/staticSerchs;JPaneljpl=newJPanel();JLabelSCH=newJLabel(查询学生信息,JLabel.CENTER);JLabellabel1=newJLabel(请输入学号:,JLabel.CENTER);JButtonserch=newJButton(查询);JLabellabel2=newJLabel(姓名:,JLabel.CENTER);JLabellabel3=newJLabel(班级:,JLabel.CENTER)
本文标题:学生信息管理系统+SQL数据库
链接地址:https://www.777doc.com/doc-6321249 .html