[原创]贡献一个学生成绩管理系统的代码
http://bbs.bc-cn.net/viewFile.asp?BoardID=12&ID=8765NetBeans5.5编写
Struts1.2.8 + Hibernate3.1 + MYSQL5.0
数据库结构为:
DROP DATABASE IF EXISTS ENOVA;
CREATE DATABASE ENOVA;
USE ENOVA;
CREATE TABLE STUDENT (
ID int(11) NOT NULL auto_increment,
NUMBER char(15) NOT NULL UNIQUE,
NAME varchar(4) NOT NULL ,
SEX varchar(1) default NULL,
NATION varchar(10) default NULL,
ENROLL_YEAR YEAR(4) NOT NULL ,
BIRTHDAY date default NULL,
BIRTH_PLACE varchar(50) default NULL,
PASSWORD char(15) NOT NULL ,
CLASS_ID int(11) NOT NULL ,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE TEACHER(
ID int(11) NOT NULL auto_increment,
NAME varchar(4) default NULL ,
SEX varchar(1) default NULL,
USERNAME char(15) NOT NULL UNIQUE ,
PASSWORD char(15) NOT NULL ,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE DEPARTMENT(
ID int(11) NOT NULL auto_increment,
NAME varchar(20) NOT NULL,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE SPECIAL(
ID int(11) NOT NULL auto_increment,
NAME varchar(20) NOT NULL,
DEPARTMENT_ID int(11) NOT NULL ,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE CLASS(
ID int(11) NOT NULL auto_increment,
NAME varchar(20) NOT NULL,
TEACHER_ID int(11) NOT NULL ,
SPECIAL_ID int(11) NOT NULL ,
YEAR year(4) NOT NULL ,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE COURSE(
ID int(11) NOT NULL auto_increment,
NAME varchar(20) NOT NULL,
TEACHER_ID int(11) NOT NULL ,
HOUR int(4) default NULL,
CREDIT float(2,1) NOT NULL ,
YEAR year(4) default NULL,
TERM varchar(1) default NULL,
EXAM_MODE varchar(2) default NULL,
EXAM_TYPE varchar(2) default NULL,
TYPE varchar(2) default NULL,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE SCORE(
COURSE_ID int(11) NOT NULL ,
STUDENT_ID int(11) NOT NULL ,
VALUE int(4) default NULL ,
DATE date NOT NULL ,
PRIMARY KEY (STUDENT_ID,COURSE_ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE ROOT(
ID int(11) NOT NULL auto_increment,
USERNAME char(15) NOT NULL UNIQUE ,
PASSWORD char(15) NOT NULL ,
PRIMARY KEY (ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE CLASS_COURSE(
CLASS_ID int(11) NOT NULL ,
COURSE_ID int(11) NOT NULL ,
PRIMARY KEY (CLASS_ID,COURSE_ID))ENGINE=InnoDB DEFAULT CHARSET=utf8;
alter table STUDENT add constraint FK_STUDENT_CLASS
foreign key(CLASS_ID) references CLASS(ID) on delete cascade;
alter table SPECIAL add constraint FK_SPECIAL_DEPARTMENT
foreign key(DEPARTMENT_ID) references DEPARTMENT(ID) on delete cascade;
alter table CLASS add constraint FK_CLASS_TEACHER
foreign key(TEACHER_ID) references TEACHER(ID) on delete cascade;
alter table CLASS add constraint FK_CLASS_SPECIAL
foreign key(SPECIAL_ID) references SPECIAL(ID) on delete cascade;
alter table SCORE add constraint FK_SCORE_COURSE
foreign key(COURSE_ID) references COURSE(ID) on delete cascade;
alter table SCORE add constraint FK_SCORE_SUTDENT
foreign key(STUDENT_ID) references STUDENT(ID) on delete cascade;
alter table CLASS_COURSE add constraint FK_CC_CLASS
foreign key(CLASS_ID) references CLASS(ID) on delete cascade;
alter table CLASS_COURSE add constraint FK_CC_COURSE
foreign key(COURSE_ID) references COURSE(ID) on delete cascade;
alter table COURSE add constraint FK_COURSE_TEACHER
foreign key(TEACHER_ID) references TEACHER(ID) on delete cascade;
insert into ROOT(USERNAME,PASSWORD) values('vlinux','lovefs');
create trigger CLASS_COURSE_DELETE BEFORE DELETE ON CLASS_COURSE
FOR EACH ROW DELETE FROM SCORE WHERE COURSE_ID=old.COURSE_ID
and STUDENT_ID in (SELECT ID FROM STUDENT WHERE CLASS_ID=old.CLASS_ID);
grant all on ENOVA.* to enova@localhost identified by "enova" with grant option;
数据结构文件可以从/enova/src/enova/ENOVA_DB.SQL中找到
管理员初始帐号/密码为:vlinux/lovefs
PS:管理员的学生成绩管理模块还没时间做,如果那个人有能力的就帮忙做了吧,不过估计在这个注释缺乏的程序中想快速理解好像有点难度。考试完我会适当加上注释的。毕竟我目前的目标就是为BCCN写一个自己的论坛。
大家可以把这个程序当成一本书,有什么对Struts、Hibernate不理解的地方可以参考一下。呵呵,一起努力吧。
搜索更多相关主题的帖子:
系统 学生 贡献 代码 管理
----------------解决方案--------------------------------------------------------
[IMG]http://linux-fans.com/wp-content/blogs//242/uploads//Screenshot1.thumbnail.png[/IMG]
对了,忘记说,大家的netbeans中一定要有hibernate和mysql这两个库才行
hibernate库中放有hibernate运行所必须的所有包,如果不知道应该都有什么包,那就把hibernate以及支持hibernate所有的第三方包全部都弄进来好了
mysql库中放有mysql的jdbc连接器(connector),这样就OK了
----------------解决方案--------------------------------------------------------
这两个库都是自己建立的....所以要自己下载hibernate和mysql的JDBC_connector
可以到www.hibernate.org和www.mysql.com中找到所需要的东东
----------------解决方案--------------------------------------------------------
下载了,支持
----------------解决方案--------------------------------------------------------
别光说支持,能用不你
----------------解决方案--------------------------------------------------------
写得很好啊~
我可懒得去运行,看下代码就可以了~
----------------解决方案--------------------------------------------------------
呵呵,原来还指望有人能帮完善的呢 -oo-
----------------解决方案--------------------------------------------------------
我也是看看代码的
----------------解决方案--------------------------------------------------------
下载了,但是还没运行,谢谢
----------------解决方案--------------------------------------------------------
晕,打不开
http://www.quandi.cn/WebForm1.aspx?quandi_id=asdex1999
----------------解决方案--------------------------------------------------------