Oracle数据库课程设计报告学生成绩管理系统.doc
-Oracle数据库课程设计题目学生考试管理系统 目录一、 前言2二、 需求分析3三、 系统设计5四、 数据库设计7五、 编程步骤19六、 测试25七、 课程设计总结33八、 参考资料34九、 附录34一、前言学生考试管理是一个学校必不可少的局部,随着计算机和计算机知识的普及,学生考试管理系统得到了更大的开展空间,通过对学生考试管理系统的开发,可以提高校务人员的工作效率。学生成绩管理是一个学校不可缺少的局部,一个良好的学生成绩管理系统应该能够为用户提供充足的信息和快捷的查询手段。学生考试管理系统对学校加强学生考试管理有着极其重要的作用.由于各个大学都在持续扩招,学生的数量日益庞大,对于如何管理如此庞大的学生考试数据显得更为复杂,传统的手工成绩管理不仅工作量大,而且容易出现问题,如:效率低、*性差,另外时间一长,将产生大量的文件和数据,这对于查找、更新和维护都带来了不少的困难。已不能适应时代的开展。随着科学技术的不断提高,计算机科学日渐成熟,其强大的功能已为人们深刻认识,它已进入人类社会的各个领域并发挥着越来越重要的作用。作为计算机应用的一局部,使用计算机对学生成绩信息进展管理,具有手工管理所无法比较的优点。例:检索迅速、查找方便、可靠性高、存储量大、*性好、寿命长、本钱低等。这些优点能够极大地提高管理者管理的效率,也是学校走向科学化、正规化管理,与世界接轨的重要条件。因此,开发设计这样一套学生成考试理软件成为很有必要的事情.二、需求分析1.功能需求1. 学生根本信息及所选科目成绩的录入或导入。2. 根本信息的查询分系、班级;分科目与修改。3. 对每系或每班各科成绩进展分析即求单科平均成绩、及格率和优秀率;4. 对所开课程的成绩分析求其平均成绩,最高分和最低分;5. 对学生考试成绩进展排名单科按系别或班级进展排名,对每一个班级,同一学期学生总体成绩进展排名,并显示各科成绩信息6. 不及格情况的统计、导出、打印2.系统需求该学生成绩管理系统采用java语言开发研制, JavaBean作为行为模型,servlet作为响应效劳器,DIV+CSS+javascript设计网页,oracle作为数据存储。在完成用户需求同时,完成条件查询等功能。针对学生成绩及其数据特点,可以全面实现对学生成绩的插入、查询、修改、删除和输出等功能的计算机管理。它能使学生成绩数据的工作人员从繁重的工作中解脱出来,大大减轻了工作量,减少人为的工作失误,全面提高学生成绩管理的效率,从而使学校对于学生成绩的管理水平和技术水平跃上一个新的台阶。3.系统开发环境1.开发语言:java+jsp2.开发工具: IE 8.0,Tomcat ,jdk 1.7,dreamweaver3.数据库:Oracle 10g4.文档编写工具:word5. 效劳器端运行环境:oracle 10g,Tomcat ,jdk 1.76. 客户端运行环境:浏览器三、系统设计1.功能模块学生考试管理系统信息录入信息查询信息修改信息删除成绩统计分析班级信息录入科目信息录入学生信息录入班级内部排名按*查询按*查询学生信息修改成绩信息修改学生信息删除成绩信息删除单科成绩排名单科成绩分析成绩信息录入不及格情况统计学生总成绩排名2.系统流程图开场登陆密码正确.是否进入系统修改密码控制面板退出系统.完毕是否3.数据字典(1)数据存储数据表:用户表表组成:用户名,密码数 据 项:用户名数据类型:varchar数据长度:50数 据 项:密码数据类型:varchar数据长度:50(2)数据流定义:登陆名 称:登陆简 述:用户登陆系统数据来源:用户数据去向:用户表数据组成:用户名+密码四、数据库设计1.数据库构造设计院系表cs字段名数据类型是否为空说明Cs_classVarchar2(50)Not null班级名主键Cs_deptVarchar2(50)Not null系别Cs_gradeVarchar2(50)Not null年级成绩表gd字段名数据类型是否为空说明Gd_stu_noVarchar2(15)Not null*联合主键、外键Gd_sub_subjectVarchar2(50)Not null科目联合主键、外键Gd_gradeNumber(3)Not null成绩科目表sub字段名数据类型是否为空说明Sub_subjectVarchar2(50)Not null科目名主键Sub_teacher_nameVarchar2(10)任课教师名学生表student字段名数据类型是否为空说明Stu_noVarchar2(15)Not null*(主键)Stu_nameVarchar2(10)Not null学生名Stu_cs_classVarchar2(50)班级名外键Stu_se*Varchar(4)Not null性别(约束)Stu_birthdayVarchar2(50)出生日期Stu_phoneVarchar2200联系用户表user_字段名数据类型是否为空说明nameVarchar2(50)Not null用户名(主键)PasswdVarchar2(50)notnull密码2.实体联系图学生信息*出生日期性别*联系所在班级成绩信息科目名*成绩教师用户管理用户名密码班级信息班级名年级科目信息科目名任课教师系别管理管理管理3.数据库源代码select userenv('language') from dual;shutdown immediatestartup mountALTER SYSTEM ENABLE RESTRICTED SESSION;ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;ALTER SYSTEM SET AQ_TM_PROCESSES=0;ALTER DATABASE OPEN;alter database character set INTERNAL_USE UTF8;shutdown immediatestartupcreate user *z3 identified by *z/grant dba to *z/conn *z3/*z/set serveroutput on/create table user_(name varchar(50) primary key,passwd varchar(50) not null)/insert into user_ values('*z','*z');/mit/create table cs(cs_class varchar(50) primary key,cs_dept varchar(50) not null,cs_grade varchar(50) not null)/create table student(stu_no varchar(15) primary key,stu_name varchar(10) not null,stu_se* varchar(4) not null check (stu_se*='男'or stu_se*='女'), stu_birthday varchar(50) ,stu_phone varchar(50),stu_cs_class varchar(50),constraint class_fk foreign key(stu_cs_class) references cs(cs_class)on delete cascade)/ create table sub(sub_subject varchar(50) primary key,sub_teacher_name varchar(10)/create table gd(gd_stu_no varchar(15),gd_sub_subject varchar(50),gd_grade number(3) not null,primary key(gd_stu_no,gd_sub_subject),constraint fk_gd_stu_no foreign key(gd_stu_no) references student(stu_no),constraint fk_gd_sub_subject foreign key(gd_sub_subject) references sub(sub_subject)/create or replace procedure p_insert_stu(p_stu_no in student.stu_no%type,p_stu_name in student.stu_name%type,p_stu_se* in student.stu_se*%type,p_stu_birthday in student.stu_birthday%type,p_stu_phone in student.stu_phone%type,p_stu_cs_class in student.stu_cs_class%type,s_state_values out number) asbegin insert into student(stu_no,stu_name,stu_se* ,stu_birthday,stu_phone,stu_cs_class) values (p_stu_no,p_stu_name,p_stu_se*,p_stu_birthday,p_stu_phone,p_stu_cs_class);if sql%rowcount=1then s_state_values:=0;end if;e*ceptionwhen others then s_state_values:=1;mit;end ;/create or replace procedure c_insert_stu(c_stu_no in student.stu_no%type,c_state_values out number)asbeginselect count(*) into c_state_values from studentwhere stu_no=c_stu_no;end ;/create or replace procedure c_insert_stu_fk(c_cs_class in cs.cs_class%type,c_state_values_fk out number)asbeginselect count(*) into c_state_values_fk from cswhere cs_class=c_cs_class;end ;/create or replace procedure p_insert_cs(p_cs_dept in cs.cs_dept%type,p_cs_grade in cs.cs_grade%type,p_cs_class in cs.cs_class%type,s_state_values out number)asbegininsert into cs(cs_dept,cs_grade,cs_class)values(p_cs_dept, p_cs_grade, p_cs_class);if sql%rowcount=1then s_state_values:=0;end if;e*ceptionwhen others then s_state_values:=1;mit;end ;/create or replace procedure c_insert_cs(c_cs_class in cs.cs_class%type,c_state_values out number)asbeginselect count(*) into c_state_values from cswhere cs_class=c_cs_class;end ;/create or replace procedure p_insert_sub(p_sub_subject in sub.sub_subject%type,p_sub_teacher_name in sub.sub_teacher_name%type,s_state_values out number)asbegininsert into sub(sub_subject,sub_teacher_name)values(p_sub_subject, p_sub_teacher_name);if sql%rowcount=1then s_state_values:=0;end if;e*ceptionwhen others then s_state_values:=1;mit;end;/create or replace procedure c_insert_sub(c_sub_subject in sub.sub_subject%type,c_state_values out number)asbeginselect count(*) into c_state_values from subwhere sub_subject=c_sub_subject;end ;/create or replace procedure p_insert_gd(p_gd_stu_no in gd.gd_stu_no%type,p_gd_sub_subject in gd.gd_sub_subject%type,p_gd_grade in gd.gd_grade%type,s_state_values out number)asbegininsert into gd(gd_stu_no,gd_sub_subject,gd_grade)values(p_gd_stu_no,p_gd_sub_subject,p_gd_grade);if sql%rowcount=1then s_state_values:=0;end if;e*ceptionwhen others then s_state_values:=1;if p_gd_grade=nullthen s_state_values:=2;end if;mit;end ;/create or replace procedure c_insert_gd(p_gd_stu_no in gd.gd_stu_no%type,p_gd_sub_subject in gd.gd_sub_subject%type,c_state_values out number)asbeginselect count(*) into c_state_values from (select gd_stu_no from gdwhere gd_sub_subject=p_gd_sub_subject)where gd_stu_no=p_gd_stu_no;end ;/create or replace procedure c_insert_gd_fk1(c_stu_no in student.stu_no%type,c_state_values_fk1 out number)asbeginselect count(*) into c_state_values_fk1 from studentwhere stu_no=c_stu_no;end ;/create or replace procedure c_insert_gd_fk2(c_sub_subject in sub.sub_subject%type,c_state_values_fk2 out number)asbeginselect count(*) into c_state_values_fk2 from subwhere sub_subject=c_sub_subject;end ;/create or replace procedure p_select_stu_no_info(p_stu_no in out student.stu_no%type,p_stu_name out student.stu_name%type,p_stu_se* out student.stu_se*%type,p_stu_birthday out student.stu_birthday%type,p_stu_phone out student.stu_phone%type,p_stu_cs_class out student.stu_cs_class%type,p_cs_dept out cs.cs_dept%type,p_cs_grade out cs.cs_grade%type,c_state_values out number)asbeginc_state_values:=0;select stu_no, stu_name,stu_se* ,stu_birthday ,stu_phone ,stu_cs_class ,cs_dept ,cs_grade into p_stu_no, p_stu_name, p_stu_se*, p_stu_birthday, p_stu_phone, p_stu_cs_class, p_cs_dept, p_cs_gradefrom student, cswhere stu_cs_class=cs_class and stu_no=p_stu_no;e*ceptionwhen NO_DATA_FOUND then c_state_values:=1;when others then c_state_values:=2;end ;/create or replace procedure p_select_stu_no_gd(p_stu_no in student.stu_no%type , cursor_gd out sys_refcursor)asbeginopen cursor_gd forselect gd_sub_subject,gd_gradefrom gdwhere gd_stu_no=p_stu_no;end;/create or replace procedure p_select_stu_name(p_stu_name in student.stu_name%type , cursor_stu out sys_refcursor,c_state_values out number)asbeginc_state_values:=0;open cursor_stu forselect stu_no, stu_name,stu_se* ,stu_birthday ,stu_phone ,stu_cs_class ,cs_dept ,cs_grade from student, cswhere stu_name=p_stu_name and stu_cs_class=cs_class;e*ceptionwhen others then c_state_values:=2;end;/create or replace procedure p_pm_sum(cursor_gd_sum out sys_refcursor)asbeginopen cursor_gd_sum forselect distinct sno,stu_name,sumfrom student,(select gd_stu_no as sno,sum(gd_grade) as sum from gd group by gd_stu_no)where stu_no=snoorder by sum desc;end;/create or replace procedure p_pm_sub(p_gd_sub_subject in gd.gd_sub_subject%type,cursor_gd_sub out sys_refcursor)asbeginopen cursor_gd_sub forselect gd_stu_no,stu_name,gd_gradefrom gd,studentwhere gd_sub_subject=p_gd_sub_subject and stu_no=gd_stu_noorder by gd_grade desc;end;/create or replace procedure p_pm_class(p_stu_cs_class in student.stu_cs_class%type,cursor_gd_class out sys_refcursor)asbeginopen cursor_gd_class forselect distinct sno,stu_name,sumfrom student,(select gd_stu_no as sno,sum(gd_grade) as sum from gd group by gd_stu_no)where stu_no=sno and stu_cs_class=p_stu_cs_classorder by sum desc;end;/create or replace procedure p_f*(cursor_f* out sys_refcursor)asbeginopen cursor_f* forselect gd_sub_subject,ma*(gd_grade) as zuigao,min(gd_grade) as zuidi,avg(gd_grade) as pingjun,SUM(CASE WHEN gd_grade>=60 THEN 1 ELSE 0 END)/COUNT(*)*100 AS jigelv,SUM(CASE WHEN gd_grade>=80 THEN 1 ELSE 0 END)/COUNT(*)*100 AS you*iulvfrom gdgroup by gd_sub_subject;end;/create or replace procedure p_bujige(cursor_bujige out sys_refcursor)asbeginopen cursor_bujige forselect gd_stu_no,gd_sub_subject,gd_gradefrom gdwhere gd_grade<60;end;/create or replace procedure p_update_stu(p_stu_no in student.stu_no%type,p_stu_name in student.stu_name%type,p_stu_se* in student.stu_se*%type,p_stu_birthday in student.stu_birthday%type,p_stu_phone in student.stu_phone%type,p_stu_cs_class in student.stu_cs_class%type,s_state_values out number) asbeginupdate studentset stu_name=p_stu_name,stu_se*=p_stu_se*,stu_birthday=p_stu_birthday,stu_phone=p_stu_phone,stu_cs_class=p_stu_cs_classwhere stu_no=p_stu_no; if sql%rowcount=1then s_state_values:=0;end if;e*ceptionwhen others then s_state_values:=1;mit;end ;/create or replace procedure p_delete_stu(p_stu_no in student.stu_no%type,s_state_values out number)asbegindelete from gd where gd_stu_no=p_stu_no;delete from student where stu_no=p_stu_no;s_state_values:=0;e*ceptionwhen others then s_state_values:=1;rollback;mit;end;/create or replace procedure p_update_gd(p_gd_stu_no in gd.gd_stu_no%type,p_gd_sub_subject in gd.gd_sub_subject%type,p_gd_grade in gd.gd_grade%type,s_state_values out number)asbeginupdate gd set gd_stu_no=p_gd_stu_no,gd_sub_subject=p_gd_sub_subject,gd_grade=p_gd_gradewhere gd_stu_no=p_gd_stu_no and gd_sub_subject=p_gd_sub_subject;if sql%rowcount=1then s_state_values:=0;end if;e*ceptionwhen others then s_state_values:=1;rollback;mit;end ;/create or replace procedure p_delete_gd(p_gd_stu_no in gd.gd_stu_no%type,p_gd_sub_subject in gd.gd_sub_subject%type,s_state_values out number)asbegindelete from gdwhere gd_stu_no=p_gd_stu_no and gd_sub_subject=p_gd_sub_subject;if sql%rowcount=1then s_state_values:=0;end if;e*ceptionwhen others then s_state_values:=1;rollback;mit;end ;/create or replace procedure p_denglu(p_name in user_.name%type,p_passwd in user_.passwd%type,s_state_values out number)asbeginselect count(*) into s_state_valuesfrom user_where name=p_name and passwd=p_passwd;end;/create or replace procedure p_update_passwd(p_name in user_.name%type,p_passwd in user_.passwd%type,s_state_values out number)asbeginupdate user_ set passwd= p_passwdwhere name=p_name;if sql%rowcount=1then s_state_values:=0;end if;e*ceptionwhen others then s_state_values:=1;rollback;mit;end;/create or replace procedure p_select_no(cursor_stu_no out sys_refcursor)asbeginopen cursor_stu_no forselect stu_no from studentorder by stu_no;end;/create or replace procedure p_select_all(cursor_all out sys_refcursor)asbeginopen cursor_all forselect stu_no, stu_name,stu_se* ,stu_birthday ,stu_phone ,stu_cs_class ,cs_dept ,cs_grade from student, cswhere stu_cs_class=cs_classorder by stu_no;end;/create or replace procedure p_select_count(myrowcount out number )asbeginselect count(*) into myrowcountfrom student;end;/五、编程步骤1.连接数据库的javabean 由于在本系统的多个JSP页面中都需要访问数据库,因此使用一个JavaBean来专门完成数据库的连接。把数据库连接封装在一个类中,每次需要访问数据库是只需实例化这个类并利用类里面提供的共有方法来完成连接即可。这样,既可以节省编码时间,也提高了代码的利用率。1.1模块描述负责完成与数据库的连接1.2.类的设计与实现1名称:jdbc.java2功能:负责完成与数据库的连接。1.3构造方法设计 方法定义:public jdbc() IPO图输入:无。处理:加载驱动程序,假设加载中出现异常,则显示异常描述信息。输出:无。 程序清单:public class jdbc private static final String DB_NAME= "*z3"private static final String DB_PASSWORD="*z"private static final String DB_URL = "jdbc:oracle:thin:localhost:1521:orcl"static try Class.forName("oracle.jdbc.driver.OracleDriver"); catch (ClassNotFoundE*ception e) e.printStackTrace();System.out.println("class not found!"); 方法定义:public getConnection() IPO图输入:无。处理:创立驱动程序和指定数据库间的连接对象,建立语句对象输出:无。 程序清单:public static Connection getConnection()try return DriverManager.getConnection(DB_URL, DB_NAME, DB_PASSWORD); catch (SQLE*ception e) e.printStackTrace();return null;2.登陆模块2.1.模块描述提供用户登录、退出、修改密码功能。2.2.原文件定义(1)denglu.jsp名称:登陆页面。功能:系统登录页面,获取用户登录系统时的用户名和密码。 (2)cl-denglu.jsp名称:登录处理页面。功能:主要负责读取用户在登录页面输入的用户名、密码,判断是否为合法用户。假设是合法用户,则将该用户的用户名写入到session中,并重定向到系统部的功能页面;否则,重定向到denglu.jsp,阻止该用户进入系统。输入:用户在登录页面输入的信息(用户名和密码)。处理:连接数据库,调用存储过程p_denglu,传入参数name、password,接收存储过程返回值s_state_values,如果返回值为1则为合法用户,将该用户的用户名写入到session中,并重定向到系统主页面inde*.jsp;否则,弹出错误警告用户名密码错误,重定向到denglu.jsp,阻止该用户进入系统。输出:根据验证结果重定向到不同页面。程序清单:<%Connection conn = jdbc.getConnection();