学生信息管理系统+SQL数据库
- 格式:doc
- 大小:67.50 KB
- 文档页数:14
本科生课程设计课程名称数据库原理及应用课程设计课程编号J1670101学号学生姓名所在专业所在班级指导教师成绩教师签字年月日课程设计时间:年月日至年月日目录目录设计总说明 (I)1、需求分析 (3)2、概念结构设计 (3)3、逻辑结构设计 (4)4、物理结构设计 (4)5、系统实现 ....................................................................................... 错误!未定义书签。
5.1前台界面 .................................................................................. 错误!未定义书签。
5.2 后台实现 .................................................................................. 错误!未定义书签。
6、优缺点及自我评价....................................................................... 错误!未定义书签。
7、参考文献 (7)设计总说明(1)系统开发目的学生信息管理系统是学校管理的重要工具,是学校不可或缺的部分。
随着在校大学生人数的不断增加,教务系统的数量也不断的上涨。
学校工作繁杂、资料众多,人工管理信息的难度也越来越大,显然是不能满足实际的需要,效率也是很低的。
并且这种传统的方式存在着很多的弊端,如:保密性差、查询不便、效率低,很难维护和更新等。
然而,本系统针对以上缺点能够极大地提高学生信息管理的效率,也是科学化、正规化的管理,与世界接轨的重要条件。
所以如何自动高效地管理信息是这些年来许多人所研究的。
(2)开发内容用数据库和Java相关技术开发一个学生信息管理系统(3)开发要求能够对学生信息进行简单的添加,删除和查询(4)开发环境及工具1、操作系统:Windows 72、数据库软件:SQL Server 20083、Java开发工具:Eclipse(5)系统功能简介一、学生管理1、添加学生信息。
学生宿舍管理系统sql报告1. 引言学生宿舍管理系统是一种用于管理学生宿舍信息的系统。
该系统可以帮助学校管理部门对学生宿舍情况进行有效的统计和管理,包括学生入住情况、宿舍楼信息以及宿舍楼管理员等。
本报告将详细介绍学生宿舍管理系统的数据库设计和SQL查询操作。
2. 数据库设计为了实现学生宿舍管理系统,设计了以下五张表格:2.1 学生表格(students)属性类型约束说明-id int 主键、自增学生IDname varchar 学生姓名gender varchar 学生性别dorm_id int 外键所属宿舍ID2.2 宿舍表格(dormitories)属性类型约束说明- -id int 主键、自增宿舍IDbuilding varchar 宿舍楼号room int 宿舍房号capacity int 宿舍容量admin_id int 外键宿舍管理员ID2.3 宿舍管理员表格(administrators)属性类型约束说明-id int 主键、自增管理员IDname varchar 管理员姓名2.4 楼栋表格(buildings)属性类型约束说明-id int 主键、自增楼栋IDname varchar 楼栋名称2.5 学生宿舍分配表格(allocation)属性类型约束说明-id int 主键、自增分配记录IDstudent_id int 外键学生IDdorm_id int 外键宿舍IDdate date 分配日期3. SQL查询操作学生宿舍管理系统可以进行多种查询操作,我们将介绍其中几个常用的查询操作。
3.1 查询某个宿舍楼的学生入住情况sqlSELECT s.id, , s.gender, d.building, d.roomFROM students AS sJOIN dormitories AS dON s.dorm_id = d.idWHERE d.building = 'A'该查询操作将返回宿舍楼号为A的所有学生的学生ID、学生姓名、学生性别、宿舍楼号以及宿舍房号。
原创SQL数据库学生管理系统一、简介SQL数据库学生管理系统是一款用于管理学生信息的数据库系统。
该系统采用结构化查询语言(SQL)作为数据管理和查询的工具,通过对学生信息进行有效的组织和管理,实现了学生基本信息的录入、查询、修改和删除等功能。
本文将介绍该数据库系统的设计思路、功能模块和操作流程。
二、数据库设计1. 数据表设计数据库中包含以下几个数据表:•学生表(students):存储学生的基本信息,包括学生ID、姓名、性别、年龄等字段。
•课程表(courses):存储学生所选课程的信息,包括课程ID、课程名称、学分等字段。
•成绩表(scores):存储学生的成绩信息,包括学生ID、课程ID、成绩等字段。
2. 数据库关系设计学生表与课程表之间的关系是多对多关系,通过中间表(选课表)来建立关联关系。
选课表(selections)包含了学生ID和课程ID两个字段,用于记录学生所选课程的关系。
各个数据表之间的关系如下图所示:+------------+| students |+------------+|| 多对多关系|+------------+| courses |+------------+|| 一对多关系|+------------+| scores |+------------+三、功能模块SQL数据库学生管理系统包含以下几个功能模块:1. 学生信息管理模块该模块实现学生信息的录入、查询、修改和删除功能。
管理员可以通过该模块进行学生信息的管理,包括添加新的学生信息、查询学生信息、修改学生信息和删除学生信息等操作。
2. 课程信息管理模块该模块实现课程信息的录入、查询、修改和删除功能。
管理员可以通过该模块进行课程信息的管理,包括添加新的课程信息、查询课程信息、修改课程信息和删除课程信息等操作。
3. 成绩管理模块该模块实现学生成绩的录入、查询、修改和删除功能。
管理员可以通过该模块进行学生成绩的管理,包括添加学生成绩、查询学生成绩、修改学生成绩和删除学生成绩等操作。
sql课程设计学生管理系统一、教学目标本课程的目标是使学生掌握SQL语言的基本知识,能够使用SQL语言进行数据库的增删改查操作,并能够运用SQL语言进行简单的数据库设计与优化。
在技能目标方面,学生应能够熟练使用数据库管理系统,进行数据库的创建、表的创建、数据的插入、查询、更新和删除等操作。
在情感态度价值观目标方面,学生应能够理解数据库在信息社会中的重要作用,认识到数据安全和数据保护的重要性,培养良好的数据管理和保护意识。
二、教学内容本课程的教学内容主要包括SQL语言的基本语法、数据库的创建和管理、表的创建和管理、数据的增删改查操作、SQL查询语句的编写等。
具体的教学内容安排如下:1.第一章:SQL语言简介1.1 SQL语言的背景与发展1.2 SQL语言的基本语法2.第二章:数据库的创建和管理2.1 数据库的创建2.2 数据库的删除与修改3.第三章:表的创建和管理3.1 表的创建3.2 表的删除与修改4.第四章:数据的增删改查操作4.1 数据的插入4.2 数据的删除与更新4.3 数据的查询5.第五章:SQL查询语句的编写5.1 单表查询5.2 多表查询三、教学方法本课程的教学方法主要包括讲授法、案例分析法和实验法。
在教学过程中,教师将首先通过讲授法向学生介绍SQL语言的基本概念和语法,然后通过案例分析法引导学生掌握SQL语言的实际应用,最后通过实验法让学生亲手操作数据库,巩固所学知识。
四、教学资源本课程的教学资源包括教材、多媒体资料和实验设备。
教材将为学生提供全面、系统的SQL语言知识,多媒体资料将帮助学生更好地理解和掌握SQL语言的应用,实验设备将允许学生进行实际操作,提高其实际应用能力。
五、教学评估本课程的评估方式包括平时表现、作业和考试。
平时表现将占课程总评的30%,主要评估学生在课堂上的参与程度和提问回答情况。
作业将占课程总评的40%,主要评估学生的学习效果和理解能力。
考试将占课程总评的30%,主要评估学生的综合运用能力。
基于SQL数据库设计的学生成绩管理系统随着教育信息化的不断深入,学生成绩管理系统在学校教务管理中扮演着越来越重要的角色。
为了更好地管理学生成绩信息,提高教学效率,设计一个基于SQL数据库的学生成绩管理系统显得尤为重要。
本文将从数据库设计的角度出发,探讨如何构建一个高效、稳定的学生成绩管理系统。
1. 数据库设计在设计学生成绩管理系统的数据库时,首先需要考虑的是数据库的表结构。
一般来说,可以设计以下几张表:学生表(Student):包含学生的基本信息,如学号、姓名、性别、年龄等字段。
课程表(Course):包含课程的信息,如课程编号、课程名称、学分等字段。
成绩表(Score):记录学生的成绩信息,包括学生学号、课程编号、成绩等字段。
2. 数据库关系在学生成绩管理系统中,不同表之间存在着一定的关系。
一般来说,可以建立以下几种关系:学生与成绩之间是一对多的关系,即一个学生可以有多条成绩记录。
课程与成绩之间是多对一的关系,即多个学生可以选择同一门课程。
3. SQL查询设计完数据库结构和关系后,接下来就是编写SQL查询语句来实现对学生成绩信息的增删改查操作。
以下是一些常用的SQL查询语句示例:查询某个学生的所有成绩:SELECT * FROM Score WHEREstudent_id = 'xxx';查询某门课程的平均成绩:SELECT AVG(score) FROM Score WHERE course_id = 'xxx';查询某个学生某门课程的成绩:SELECT score FROM Score WHERE student_id = 'xxx' AND course_id = 'xxx';4. 数据库优化为了提高系统性能和查询效率,需要对数据库进行优化。
可以采取以下措施:添加索引:对经常用于查询条件的字段添加索引,加快查询速度。
规范化设计:避免数据冗余和不一致,提高数据存储效率。
课程设计任务书题目:学生管理系统学姓专课号名业程信息科学与工程学院数据库技术与应用指导教师职称讲师完成时间:2011年06 月----2010 年07 月枣庄学院计算机科学系制目录1学生信息管理系统概述 (5)1.1系统的任务 (5)1.2系统的目标 (5)2系统具体需求分析 (6)2.1系统需求 (6)2.2数据字典 (6)2.3数据流图 (10)3概念结构设计 (11)4.逻辑结构设计 (14)5.物理结构设计 (15)表汇总 (15)表A—F (16)6.数据保护设计 (18)6.1防止用户直接操作数据库的方法 (18)6.2用户帐号密码的加密方法 (18)6.3角色与权限 (18)7.运行管理与维护说明 (19)8.SQL语句及部分关键JAVA语句 (20)9.心得与体会 (29)8.参考资料 (29)课程设计任务书及成绩评定课程设计的任务和具体要求数据库应用课程设计是计算机技术专业重要的实践课程之一,是在掌握程序设计语言的基础上,学习《数据库原理》课程后的一次综合实践练习。
通过本课程设计,将在课堂上了解和掌握的数据库原理以及设计阶段的方法与技术,直接运用到实际系统的开发工作中。
并且在项目小组长及成员间的合作和沟通中,体验软件项目管理技能和方法,熟悉软件工具与环境。
本次课程设计要求我们小组成员间加强团队合作和沟通,同时每个成员承担明确的责任,独立按时完成相应任务;按照模版完成相应的文档,语言简洁、通顺,开发的系统功能符合需求规格,并能够准确、稳定地运行。
日期:指导教师签字:指导教师评语成绩:指导教师签字:日期:需求分析:1、学生信息管理系统概述学生信息管理系统主要用来管理学生基本信息。
本系统是一个简单的学生信息管理系统,系统管理的信息主要是学生基本信息、课程信息和学生选课信息。
系统的目的是有效地处理这些信息,同时为用户提供信息检索、信息修改和保护功能。
1.1 系统的任务学生信息管理系统是学校有效管理学生的重要工具,它的任务主要有以下几项:◆◆◆◆◆学生基本信息管理,主要负责管理学生基本信息。
学生信息管理系统完整源代码注:本系统采用C/S结构,运用Java GUI知识编写,数据库为SQL SERVER 2005,没有采用典型的三级框架结构,所以代码有冗余,仅供参考。
一、数据表及数据源首先创建数据库,包含数据表如下:数据库创建完成后,新建一个名为SIMS的数据源,不会建数据源的同学可以在去搜索创建数据源的详细步骤,这里的数据名称一定要为SIMS,否则在以后程序连接数据库的语句中会出现错误。
二、操作演示三、代码部分创建Java工程,创建名称为SIMS的包,一下Java类均包含在一个包内。
1.登录界面package SIMS;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.text.SimpleDateFormat;import java.util.*;import java.util.Date;public class login extends JFrame implements ActionListener{String userID; //保留用户输入IDString password; //保留用户输入passwordJLabel jlID=new JLabel("用户ID:"); //使用文本创建标签对象 JLabel jlPwd=new JLabel("密码:");JTextField jtID=new JTextField(); //创建ID输入框JPasswordField jpPwd=new JPasswordField(); //创建密码输入框ButtonGroup bg=new ButtonGroup(); //创建ButtonGroup组件对象JPanel jp=new JPanel(); //创建Panel容器JLabel jl=new JLabel();JRadioButton jrb1=new JRadioButton("管理员");JRadioButton jrb2=new JRadioButton("教师");JRadioButton jrb3=new JRadioButton("学生",true);JButton jb1=new JButton("登录");JButton jb2=new JButton("重置");public login(){this.setLayout(null); //设置窗口布局管理器this.setTitle("学生信息管理系统"); //设置窗口标题this.setBounds(200,150,500,300); //设置主窗体位置大小和可见性this.setVisible(true); //设置窗口的可见性this.setResizable(false);jlID.setBounds(150,60,100,20); //设置ID框属性jtID.setBounds(220,60,100,20); //设置ID输入框属性jlPwd.setBounds(150,90,100,20); //设置密码框属性jpPwd.setBounds(220,90,100,20); //设置密码输入框属性jp.setBounds(35,120,400,250); //设置JPanel容器属性jb1.setBounds(160,170,60,20); //设置登录按钮属性jb2.setBounds(250,170,60,20); //设置取消按钮属性jb1.addActionListener(this); //设置登录按钮监听器jb2.addActionListener(this); //设置取消按钮监听器jl.setBounds(340,75,130,20); //设置提示框属性bg.add(jrb1); //将所有空间加入窗体bg.add(jrb2);bg.add(jrb3);this.add(jlID);this.add(jlPwd);this.add(jtID);this.add(jpPwd);this.add(jb1);this.add(jb2);this.add(jl);jp.add(jrb1);jp.add(jrb2);jp.add(jrb3);this.add(jp);centerShell(this);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(( (screenWidth - shellWidth) / 2),((screenHeight - shellHeight) / 2) );}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(userID);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入IDpassword=jpPwd.getText(); //获取用户输入密码if(e.getSource()==jb1){ //处理登录事件if(userID.equals("") || password.equals("")){jl.setFont(new Font("red",Font.BOLD,12)); //设置提示字体jl.setForeground(Color.red);jl.setText("请输入用户ID和密码");}else{Connection con=null;try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"","");//获取连接字符串Statement stat=con.createStatement();if(jrb1.isSelected())//如果登录选中的管理员{ResultSet rs=stat.executeQuery("select * from Admin"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rss=stat.executeQuery("selectAdmin_Pwd,Admin_Name from Admin where Admin_ID='"+userID+"'");//从表Admin获取信息while(rss.next()){String str=rss.getString(1);if(str.equals(password)){new admin(rss.getString(2));//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12)); //设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}else if(jrb2.isSelected()){ResultSet rs=stat.executeQuery("select * from Teacher_Info"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rss=stat.executeQuery("selectTea_Pwd,Tea_Names from Teacher_Info where Tea_ID='"+userID+"'");//从表Teacher_Info获取信息while(rss.next()){String str=rss.getString(1);if(str.equals(password)){new teacher(rss.getString(2),userID);//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}else if(jrb3.isSelected()){ResultSet rs=stat.executeQuery("select * from Student_Info"); //判断输入用户名是否存在int flag=0;while(rs.next()){if(rs.getString(1).equals(userID)){flag=1;break;}}if(flag==0){jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("用户ID不存在");}if(flag==1){ResultSet rsss=stat.executeQuery("selectStu_Pwd,Stu_Name from Student_Info where Stu_ID='"+userID+"'");//从表Student_Info获取信息while(rsss.next()){String str=rsss.getString(1);if(str.equals(password)){new student(rsss.getString(2),userID);//创建admin窗口this.dispose(); //释放窗体}else{jl.setFont(new Font("red",Font.BOLD,12));//设置提示字体jl.setForeground(Color.red);jl.setText("密码错误");}}}}}catch(Exception ex){ex.getStackTrace();}finally{try{con.close();}catch(Exception exc){exc.printStackTrace();}}}}else if(e.getSource()==jb2){ //处理登录事件jtID.setText("");jpPwd.setText("");jrb3.setSelected(true);jl.setText("");}}public static void main(String[] args){new login();}}2.添加课程package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_course extends JFrame implements ActionListener{ static add_course ss;String courseID=""; //课程名String coursename=""; //课程名String count=""; //课时JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel jlcourseID=new JLabel("课程号:"); //使用文本框创建标签对象JLabel jlcoursename=new JLabel("课程名:");JLabel jlcount=new JLabel("课时:");JTextField jtcourseID=new JTextField(); //创建文本框对象JTextField jtcoursename=new JTextField();JTextField jtcount=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_course(){ //添加教师账号信息this.setTitle("添加课程信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlcourseID); //将控件添加到窗体this.add(title);this.add(jlcoursename);this.add(jlcount);this.add(jtcourseID);this.add(jtcoursename);this.add(jtcount);this.add(note1);this.add(note2);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加课程信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlcourseID.setBounds(180,80,100,20);jlcoursename.setBounds(180,140,100,20);jlcount.setBounds(180,200,100,20);jtcourseID.setBounds(250,80,140,20);jtcoursename.setBounds(250,140,140,20);jtcount.setBounds(250,200,140,20);note1.setBounds(400,80,140,20);note2.setBounds(400,140,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,140,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(courseID);}return false;}public void actionPerformed(ActionEvent e){courseID=jtcourseID.getText(); //获取用户输入内容coursename=jtcoursename.getText();count=jtcount.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(courseID.equals("") || coursename.equals("")){warning.setText("请输入必填信息");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Course_ID from Course");while(rs.next()){if(rs.getString(1).equals(courseID)){warning.setText("课程ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!count.equals("")){temp=stat.executeUpdate("insert intoCourse(Course_ID,Course_Name,Course_Count)values('"+courseID+"','"+coursename+"','"+count+"')");}else{temp=stat.executeUpdate("insert intoCourse(Course_ID,Course_Name) values('"+courseID+"','"+coursename+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");warning.setText("");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){warning.setText("");jtcourseID.setT ext("");jtcoursename.setText("");jtcount.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}}3.添加学生package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_student extends JFrame implements ActionListener{static add_teacher ss;String userID=""; //用户名String pwd1=""; //密码String pwd2=""; //确认密码String getsdept=""; //院系String name=""; //姓名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel note3=new JLabel("*");JLabel jlID=new JLabel("学号:"); //创建文本框对象 JLabel jlName=new JLabel("姓名:");JLabel jlPwd=new JLabel("密码:");JLabel jlPwd2=new JLabel("确认密码:");JLabel sdept=new JLabel("学院:");JTextField jtID=new JTextField();JTextField jtName=new JTextField();JPasswordField jtPwd=new JPasswordField ();JPasswordField jtPwd2=new JPasswordField ();JTextField jtsdept=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_student(){this.setTitle("添加学生账号信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlID); //将控件添加到窗体this.add(title);this.add(jlName);this.add(jlPwd);this.add(jlPwd2);this.add(sdept);this.add(jtID);this.add(jtName);this.add(jtPwd);this.add(jtPwd2);this.add(jtsdept);this.add(note1);this.add(note2);this.add(note3);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);note3.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note3.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加学生账号信息");title.setBounds(222,20,150,20);jlID.setBounds(180,60,100,20);jlName.setBounds(180,100,100,20);jlPwd.setBounds(180,140,100,20);jlPwd2.setBounds(180,180,100,20);sdept.setBounds(180,220,100,20);jtID.setBounds(250,60,140,20);jtName.setBounds(250,100,140,20);jtPwd.setBounds(250,140,140,20);jtPwd2.setBounds(250,180,140,20);jtsdept.setBounds(250,220,140,20);note1.setBounds(400,60,140,20);note2.setBounds(400,140,140,20);note3.setBounds(400,180,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,100,150,20);submit.addActionListener(this);reset.addActionListener(this);this.setSize(600,400);centerShell(this);this.setVisible(true);this.setResizable(false); //设置窗体不可变大小this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(pwd1);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入内容pwd1=jtPwd.getText();pwd2=jtPwd2.getText();getsdept=jtsdept.getText();name=jtName.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){if(userID.equals("") || pwd1.equals("") || pwd2.equals("")){ //判断是否已输入必填信息warning.setText("请输入必填信息");}else if(!pwd1.equals(pwd2)){ //判断两次输入密码是否相同warning.setText("两次输入密码不相同");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Stu_ID from Student_Info");while(rs.next()){if(rs.getString(1).equals(userID)){warning.setText("用户ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Name,Stu_Pwd,Depart)values('"+userID+"','"+name+"','"+pwd1+"','"+getsdept+"')");}else if(!name.equals("") && getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Name,Stu_Pwd) values('"+userID+"','"+name+"','"+pwd1+"')");}else if(name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Pwd,Depart) values('"+userID+"','"+pwd1+"','"+getsdept+"')");}else{temp=stat.executeUpdate("insert intoStudent_Info(Stu_ID,Stu_Pwd) values('"+userID+"','"+pwd1+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){ //重置所有控件warning.setText("");jtID.setText("");jtName.setText("");jtPwd.setText("");jtPwd2.setText("");jtsdept.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}//public static void main(String args[]){// new add_student();//}}4.添加教师package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_teacher extends JFrame implements ActionListener{static add_teacher ss;String userID=""; //用户名String pwd1=""; //密码String pwd2=""; //确认密码String getsdept=""; //院系String name=""; //姓名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel note3=new JLabel("*");JLabel jlID=new JLabel("教工号:"); //使用文本框创建标签对象 JLabel jlName=new JLabel("姓名:");JLabel jlPwd=new JLabel("密码:");JLabel jlPwd2=new JLabel("确认密码:");JLabel sdept=new JLabel("学院:");JTextField jtID=new JTextField(); //创建文本框对象JTextField jtName=new JTextField();JPasswordField jtPwd=new JPasswordField ();JPasswordField jtPwd2=new JPasswordField ();JTextField jtsdept=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_teacher(){ //添加教师账号信息this.setTitle("添加教师账号信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlID); //将控件添加到窗体this.add(title);this.add(jlName);this.add(jlPwd);this.add(jlPwd2);this.add(sdept);this.add(jtID);this.add(jtName);this.add(jtPwd);this.add(jtPwd2);this.add(jtsdept);this.add(note1);this.add(note2);this.add(note3);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);note3.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note3.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加教师账号信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlID.setBounds(180,60,100,20);jlName.setBounds(180,100,100,20);jlPwd.setBounds(180,140,100,20);jlPwd2.setBounds(180,180,100,20);sdept.setBounds(180,220,100,20);jtID.setBounds(250,60,140,20);jtName.setBounds(250,100,140,20);jtPwd.setBounds(250,140,140,20);jtPwd2.setBounds(250,180,140,20);jtsdept.setBounds(250,220,140,20);note1.setBounds(400,60,140,20);note2.setBounds(400,140,140,20);note3.setBounds(400,180,140,20);submit.setBounds(200,270,60,20);reset.setBounds(300,270,60,20);warning.setBounds(420,100,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(pwd1);}return false;}public void actionPerformed(ActionEvent e){userID=jtID.getText(); //获取用户输入内容pwd1=jtPwd.getText();pwd2=jtPwd2.getText();getsdept=jtsdept.getText();name=jtName.getText();int temp=0,flag=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(userID.equals("") || pwd1.equals("") || pwd2.equals("")){warning.setText("请输入必填信息");}else if(!pwd1.equals(pwd2)){ //判断两次输入密码是否一致warning.setText("两次输入密码不相同");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Tea_ID from Teacher_Info");while(rs.next()){if(rs.getString(1).equals(userID)){warning.setText("用户ID已存在");flag=1; //判断用户名唯一break;}}if(flag!=1){if(!name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Names,T ea_Pwd,Depart)values('"+userID+"','"+name+"','"+pwd1+"','"+getsdept+"')");}else if(!name.equals("") && getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Names,T ea_Pwd)values('"+userID+"','"+name+"','"+pwd1+"')");}else if(name.equals("") && !getsdept.equals("")){temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Pwd,Depart) values('"+userID+"','"+pwd1+"','"+getsdept+"')");}else{temp=stat.executeUpdate("insert intoTeacher_Info(Tea_ID,Tea_Pwd) values('"+userID+"','"+pwd1+"')");}}if(temp==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch(Exception ex){ex.getStackTrace();}}}else if(e.getSource()==reset){warning.setText("");jtID.setText("");jtName.setText("");jtPwd.setText("");jtPwd2.setText("");jtsdept.setText("");}}private void centerShell(JFrame shell) //窗口在屏幕中间显示{//得到屏幕的宽度和高度int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;//得到Shell窗口的宽度和高度int shellHeight = shell.getBounds().height;int shellWidth = shell.getBounds().width;//如果窗口大小超过屏幕大小,让窗口与屏幕等大if(shellHeight > screenHeight)shellHeight = screenHeight;if(shellWidth > screenWidth)shellWidth = screenWidth;//让窗口在屏幕中间显示shell.setLocation(((screenWidth - shellWidth)/ 2),((screenHeight - shellHeight)/2));}// public static void main(String[] args){// new add_teacher();// }}5.添加授课信息package SIMS;import javax.swing.*;import java.sql.*;import java.awt.*;import java.awt.event.*;public class add_tc extends JFrame implements ActionListener{static add_tc ss;String courseID=""; //课程名String teachername=""; //课程名JLabel warning=new JLabel(); //输入信息提示框JLabel title=new JLabel();JLabel note1=new JLabel("*");JLabel note2=new JLabel("*");JLabel jlcourseID=new JLabel("课程号:"); //使用文本框创建标签对象JLabel jlteachername=new JLabel("教师号:");JTextField jtcourseID=new JTextField(); //创建文本框对象JTextField jtteachername=new JTextField();JButton submit=new JButton("添加"); //创建按钮对象JButton reset=new JButton("重置");public add_tc(){ //添加授课信息this.setTitle("添加授课信息"); //设置窗口标题this.setLayout(null); //设置窗口布局管理器this.add(jlcourseID); //将控件添加到窗体this.add(jlteachername);this.add(title);this.add(jtcourseID);this.add(jtteachername);this.add(note1);this.add(note2);this.add(submit);this.add(reset);this.add(warning);title.setFont(new Font("red",Font.BOLD,15)); //设置提示字体title.setForeground(Color.red);note1.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note1.setForeground(Color.red);note2.setFont(new Font("red",Font.BOLD,20)); //设置提示字体note2.setForeground(Color.red);warning.setFont(new Font("red",Font.BOLD,12)); //设置提示字体warning.setForeground(Color.red);title.setText("添加授课信息"); //设置控件及窗体位置大小title.setBounds(222,20,150,20);jlcourseID.setBounds(180,80,100,20);jlteachername.setBounds(180,140,100,20);jtcourseID.setBounds(250,80,140,20);jtteachername.setBounds(250,140,140,20);note1.setBounds(400,80,140,20);note2.setBounds(400,140,140,20);submit.setBounds(200,250,60,20);reset.setBounds(300,250,60,20);warning.setBounds(420,140,150,20); //设置提示框位置大小submit.addActionListener(this); //添加监听器reset.addActionListener(this);this.setSize(600,400); //设置窗体大小centerShell(this); //设置窗口位置在屏幕中央this.setResizable(false); //设置窗体不可变大小this.setVisible(true); //设置窗口可见性this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public boolean equals(Object obj){ //重写equals方法判断字符串相等if(obj==null)return false;if(this == obj){return true;}if(obj instanceof String) {String str = (String)obj;return str.equals(courseID);}return false;}public void actionPerformed(ActionEvent e){courseID=jtcourseID.getText(); //获取用户输入内容teachername=jtteachername.getText();int temp=0,flag1=0,flag2=0,flag3=0;Connection con=null;if(e.getSource()==submit){ //判断是否已输入必填信息if(courseID.equals("") || teachername.equals("")){warning.setText("请输入必填信息");}else{try{String url="jdbc:odbc:SIMS"; //连接数据库con=DriverManager.getConnection(url,"",""); //获取连接字符串Statement stat=con.createStatement();ResultSet rs=stat.executeQuery("select Course_ID from Course");while(rs.next()){if(rs.getString(1).equals(courseID)){flag1=1; //判断课程ID存在break;}}ResultSet rss=stat.executeQuery("select Tea_ID fromTeacher_Info");while(rss.next()){if(rss.getString(1).equals(teachername)){flag2=1; //判断教师ID存在break;}}if(flag1!=1){warning.setText("课程ID不存在");}else if(flag2!=1){warning.setText("教师ID不存在");}ResultSet rsss=stat.executeQuery("select Course_ID,T ea_ID from tc");while(rsss.next()){if(rsss.getString(1).equals(courseID) &&rsss.getString(2).equals(teachername)){flag3=1;warning.setText("授课信息重复");。
学生信息管理系统实验报告一、实验目的。
本实验旨在通过学生信息管理系统的设计与实现,加深对数据库管理系统的理解,提高数据库设计与编程的能力。
二、实验内容。
1. 设计学生信息管理系统的数据库结构,包括学生信息、课程信息、成绩信息等;2. 使用SQL语句创建数据库表,并插入测试数据;3. 利用编程语言(如Python、Java等)实现学生信息管理系统的增删改查功能;4. 进行系统功能测试,验证系统的稳定性和准确性。
三、实验步骤。
1. 数据库设计。
根据学生信息管理系统的需求,设计数据库结构,包括学生表(学号、姓名、性别、年龄等字段)、课程表(课程号、课程名称、学分等字段)、成绩表(学号、课程号、成绩等字段)等。
2. 数据库创建与数据插入。
使用SQL语句创建数据库表,并插入测试数据,以验证数据库结构的正确性和完整性。
3. 系统实现。
利用编程语言实现学生信息管理系统的增删改查功能,包括学生信息的录入、修改、删除,成绩的查询和统计等。
4. 系统测试。
对系统进行功能测试,验证系统的稳定性和准确性,包括对数据的增删改查操作进行测试,确保系统能够正确地处理各种情况。
四、实验结果与分析。
经过实验,我们成功设计并实现了学生信息管理系统,系统能够准确地记录学生信息、课程信息和成绩信息,能够进行各种操作,并且在测试中表现稳定可靠。
五、实验总结。
通过本次实验,我们深入理解了数据库设计与编程的重要性,掌握了数据库表的设计与创建、SQL语句的使用、编程语言的应用等技能。
同时,也提高了对学生信息管理系统的整体把握能力,为今后的数据库管理与系统开发打下了坚实的基础。
六、实验心得。
通过本次实验,我们不仅学到了知识,更重要的是提高了动手能力和解决问题的能力,这对我们未来的学习和工作都有着重要的意义。
七、参考文献。
[1] 《数据库系统概论》。
[2] 《Python编程从入门到实践》。
[3] 《Java程序设计》。
以上就是学生信息管理系统实验报告的全部内容,希望能对大家有所帮助。
本人亲自做的,不需要做任何修改即可顺利运行,sql表也与程序无缝连接,没有未识别部分。
Sql 表如下:CREATE TABLE STU(学号varchar(14) PRIMARY KEY,姓名varchar(8) NOT NULL,密码varchar(8) NOT NULL,班级varchar(14) NOT NULL ,性别varchar(2),学校varchar(14) NOT NULL);CREATE TABLE TCH(用户名varchar(8) NOT NULL,密码varchar(8) NOT NULL);CREATE TABLE 成绩表(学号varchar(14) PRIMARY KEY,计算机网络varchar(8) NOT NULL,汽车概论varchar(8) NOT NULL,初级日语varchar(8) NOT NULL,接口技术varchar(8) NOT NULL,ava程序设计varchar(8) NOT NULL,数据库varchar(8) NOT NULL,大学物理varchar(8) NOT NULL);源程序代码:import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class systems extends JFrame implements ActionListener{static systems ss;JPanel panel = new JPanel();JLabel label1 = new JLabel("输入姓名:");JTextField name = new JTextField();JLabel label2 = new JLabel("密码:");JPasswordField pwd = new JPasswordField();JButton Enter = new JButton("登录");JButton Exit = new JButton("退出");String url = "D:\\Systems\\title.jpg";ButtonGroup bgp = new ButtonGroup();JRadioButton stu = new JRadioButton("学生");JRadioButton tch = new JRadioButton("教师");public systems(){super("登录系统");this.setResizable(false);JLabel img = new JLabel(new ImageIcon(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); }public void actionPerformed(ActionEvent e){if(e.getSource()==Enter){String username , password;username = name.getText();password = pwd.getText();try{Class.forName("oracle.jdbc.driver.OracleDriver");}catch (ClassNotFoundException ce){JOptionPane.showMessageDialog(ss,ce.getMessage());}if(stu.isSelected()){try{Connection con = DriverManager.getConnection("jdbc:oracle:thin:@user29:1521:XE","hr","oracle");Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery("select * from STU");while(rs.next()){if((rs.getString("学号").equals(username))&&(rs.getString("密码").equals(password))){JOptionPane.showMessageDialog(ss,"登陆成功");Students stu = new Students();}else{JOptionPane.showMessageDialog(ss,"登录失败");}}rs.close();stmt.close();}catch (SQLException se){JOptionPane.showMessageDialog(ss,se.getMessage());}}else if(tch.isSelected()){try{Connection con = DriverManager.getConnection("jdbc:oracle:thin:@user29:1521:XE","hr","oracle");Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery("select * from TCH");while(rs.next()){if((rs.getString("用户名").equals(username))&&(rs.getString("密码").equals(password))){JOptionPane.showMessageDialog(ss,"登陆成功");}else{JOptionPane.showMessageDialog(ss,"登录失败");}}}catch (SQLException se){JOptionPane.showMessageDialog(ss,se.getMessage());}}}else{System.exit(0);}}public static void main(String[] args){systems sys = new systems();}}import java.awt.*;import javax.swing.*;import java.awt.event.*;public class Students extends JFrame implements ActionListener{JMenuBar 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);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.getSource()==Item1){AddMsg ad = new AddMsg();}else if(e.getSource()==Item2){Serch ser = new Serch();}else{}}public static void main(String[] args){Students stu = new Students();}}import java.awt.*;import javax.swing.*;import java.awt.event.*;public class Teachers extends JFrame implements ActionListener {JMenuBar bar = new JMenuBar();JMenu menu1 = new JMenu("信息");JMenu menu2 = new JMenu("成绩");JMenuItem item1 = new JMenuItem("录入信息");JMenuItem item2 = new JMenuItem("录入成绩");JPanel jpl = new JPanel();public Teachers(){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);}public void actionPerformed(ActionEvent e){if(e.getSource()==item1){AddMsg msg = new AddMsg();}else{Addscore as = new Addscore();}}public static void main(String[] args){Teachers tch = new Teachers();}}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("查询学生信息",JLabel.CENTER);JLabel label1 = 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 ButtonGroup();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);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.setBounds(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);women.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(ActionEvent e){String id = num.getText();if(e.getSource()==serch){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch (ClassNotFoundException ce){JOptionPane.showMessageDialog(s,ce.getMessage());}try{Connection con = DriverManager.getConnection("jdbc:odbc:sysdb","sa","");Statement stmt = con.createStatement();ResultSet rs = stmt.executeQuery("select * from STU where ID = '" + id +"'");while(rs.next()){nam.setText(rs.getString("Name"));if(rs.getString("Sex").equals("男")){man.setSelected(true);}else{women.setSelected(true);}clas.setText(rs.getString("Class"));scl.setText(rs.getString("Collage"));}}catch (SQLException se){JOptionPane.showMessageDialog(s,se.getMessage());}}}public static void main(String[] args){Serch sch = new Serch();}}import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class AddMsg extends JFrame implements ActionListener{static AddMsg s;/*添加学生信息控件*/JPanel jpl = new JPanel();JLabel label1 = new JLabel("添加基本信息",JLabel.CENTER);JLabel label2 = 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); 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 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(100,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.setBounds(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.setBounds(240,250,90,20);jpl.add(reset);jpl.add(addmsg);}public void actionPerformed(ActionEvent e){if(e.getSource()==addmsg){String sex;if(man.isSelected()){sex="男";}else{sex="女";}try{Class.forName("oracle.jdbc.driver.OracleDriver");}catch (ClassNotFoundException ce){JOptionPane.showMessageDialog(s,ce.getMessage());}try{Connection con = DriverManager.getConnection("jdbc:oracle:thin:@user29:1521:XE","hr","oracle");Statement stmt = con.createStatement();int a = stmt.executeUpdate("insert into STU(ID , Pwd , Name , Sex , Class , Collage)values('"+num.getText()+"','"+"12345678','"+nam.getText()+"','"+sex+"','"+clas.getText() +"','"+scl.getText()+"')");if(a==1){JOptionPane.showMessageDialog(s,"已成功添加");}else{JOptionPane.showMessageDialog(s,"添加失败");}stmt.close();}catch (SQLException se){JOptionPane.showMessageDialog(s,se.getMessage());}}else{num.setText("");nam.setText("");clas.setText("");scl.setText("");num.requestFocus();}}public static void main(String[] args){AddMsg amg = new AddMsg();}}import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class Addscore extends JFrame implements ActionListener{static Addscore ss;JLabel[] label = {new JLabel("学号:") , new JLabel("计算机网络:") , new JLabel("汽车概论:") , new JLabel("初级日语:") , new JLabel("接口技术:") , new JLabel("Java程序设计:") , new JLabel("数据库:") , new JLabel("算法设计:") , new JLabel("大学物理:")};JTextField[] txt = {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("添加学生成绩" , JLabel.CENTER); Font f = new Font("黑体" , Font.BOLD , 16 );int s = 100;public Addscore(){super("添加学生信息");this.setResizable(false);this.setSize(500,600);this.setDefaultCloseOperation(EXIT_ON_CLOSE);this.setVisible(true);this.add(jpl);add.addActionListener(this);reset.addActionListener(this);jpl.setLayout(null);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++){label[i].setBounds(100,s,140,20);jpl.add(label[i]);txt[i].setBounds(260,s,140,20);jpl.add(txt[i]);s=s+40;}add.setBounds(150,s,80,20);reset.setBounds(250,s,80,20);jpl.add(add);jpl.add(reset);}public void actionPerformed(ActionEvent e){if(e.getSource()==add){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch (ClassNotFoundException ce){JOptionPane.showMessageDialog(ss,ce.getMessage());}try{Connection con = DriverManager.getConnection("jdbc:odbc:sysdb","sa","");Statement stmt = con.createStatement();int a = stmt.executeUpdate("insert into 计算机系成绩(SID , 计算机网络,汽车概论, 初级日语, 接口技术, Java程序设计, 数据库, 算法设计, 大学物理)values('"+txt[0].getText()+"','"+txt[1].getText()+"','"+txt[2].getText()+"','"+txt[3].getText()+"','" +txt[4].getText()+"','"+txt[5].getText()+"','"+txt[6].getText()+"','"+txt[7].getText()+"','"+txt[8].getT ext()+"')");if(a==1){JOptionPane.showMessageDialog(ss,"添加成功");}else{JOptionPane.showMessageDialog(ss,"添加失败");}}catch (SQLException se){JOptionPane.showMessageDialog(ss,se.getMessage());}}else{for(int i = 0 ; i<txt.length ; i++){txt[i].setText("");txt[0].requestFocus();}}}public static void main(String[] args){Addscore as = new Addscore();}}。