基于Struts开发——学生成绩管理系统
实例一:
学生查询
删除:
修改:
实例二:学生管理:
查询
实例三 成绩管理:
成绩录入
详细信息
开发工具:MyEclipse8.5+MySQL+Tomcat7.0
项目整体结构:
数据库设计:
课程表:
CREATE TABLE `kcb` (
`KCH` char(5) NOT NULL COMMENT '课程号',
`KCM` char(16) DEFAULT NULL COMMENT '课程名',
`KKXQ` decimal(5,0) DEFAULT NULL COMMENT '开课学期',
`XS` decimal(5,0) DEFAULT NULL COMMENT '学时',
`XF` decimal(5,0) DEFAULT NULL COMMENT '学分',
PRIMARY KEY (`KCH`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
学生表:
CREATE TABLE `xsb` (
`XH` char(10) NOT NULL DEFAULT '无' COMMENT '学号',
`XM` char(10) DEFAULT '无' COMMENT '姓名',
`XB` char(5) DEFAULT '男' COMMENT '性别',
`CSSJ` date DEFAULT NULL COMMENT '出生时间',
`ZY` char(12) DEFAULT '无' COMMENT '专业',
`ZXF` decimal(10,0) DEFAULT '0' COMMENT '总学分',
`BZ` varchar(200) DEFAULT '无' COMMENT '备注',
PRIMARY KEY (`XH`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
成绩表:
CREATE TABLE `cjb` (
`XH` char(6) NOT NULL COMMENT '学号',
`KCH` char(6) NOT NULL COMMENT '课程号',
`CJ` decimal(4,0) DEFAULT NULL COMMENT '成绩',
PRIMARY KEY (`XH`,`KCH`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
学生照片:
CREATE TABLE `xszp` (
`XH` char(6) NOT NULL COMMENT '学号',
`ZP` blob COMMENT '照片',
PRIMARY KEY (`XH`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
视图:
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `xs_kc_cj` AS
select `xsb`.`XH` AS `XH`, `xsb`.`XM` AS `XM`, `xsb`.`ZY` AS `ZY`, `kcb`.`KCH` AS `KCH`, `kcb`.`KCM` AS `KCM`, `cjb`.`CJ` AS `CJ` from ((`xsb` join `kcb`) left join `cjb` on (((`cjb`.`XH` = `xsb`.`XH`) and (`cjb`.`KCH` = `kcb`.`KCH`))))
存储过程:
CREATE DEFINER=`root`@`localhost` PROCEDURE `CJA_Data`(IN in_xh INT,IN in_kch INT,IN in_cj int)
BEGIN
DECLARE in_count numeric;
DECLARE in_cjb_cj numeric;
DECLARE in_xf numeric;
set in_xf =0;
set in_cjb_cj=0;
SELECT XF INTO in_xf FROM KCB WHERE KCH=in_kch;
SELECT COUNT(*) INTO in_count FROM cjb WHERE XH=in_xh AND KCH=in_kch;
IF in_count>0 THEN
SELECT CJ INTO in_cjb_cj FROM CJB WHERE XH=in_xh AND KCH=in_kch;
DELETE FROM CJB WHERE XH=in_xh AND KCH=in_kch;
IF in_cjb_cj>=60 THEN
UPDATE XSB SET ZXF=ZXF-in_xf WHERE XH=in_xh;
END IF;
END IF;
IF in_cj<>-1 THEN
INSERT INTO CJB VALUES(in_xh,in_kch,in_cj);
IF in_cj>=60 THEN
UPDATE XSB SET ZXF=ZXF+in_xf WHERE XH=in_xh;
END IF;
END IF;
COMMIT;
END
Struts Jar包:
struts.properties日志文件:
struts.i18n.encoding=UTF-8
struts.devMode = true
struts.action.extension=action,,
struts.configuration.xml.reload = true
Student实体类:
package org.vo;
import java.io.Serializable;
import java.util.Date;
public class Student implements Serializable {
private String xh;
private String xm;
private String xb;
private Date cssj;
private String zy;
private int zxf;
private String bz;
private byte[] zp;
public Student() {
// TODO Auto-generated constructor stub
}
public Student(String xh, String xm, String xb, Date cssj, String zy,
int zxf, String bz, byte[] zp) {
super();
this.xh = xh;
this.xm = xm;
this.xb = xb;
this.cssj = cssj;
this.zy = zy;
this.zxf = zxf;
this.bz = bz;
this.zp = zp;
}
public String getXh() {
return xh;
}
public void setXh(String xh) {
this.xh = xh;
}
public String getXm() {
return xm;
}
public void setXm(String xm) {
this.xm = xm;
}
public String getXb() {
return xb;
}
public void setXb(String xb) {
this.xb = xb;
}
public Date getCssj() {
return cssj;
}
public void setCssj(Date cssj) {
this.cssj = cssj;
}
public String getZy() {
return zy;
}
public void setZy(String zy) {
this.zy = zy;
}
public int getZxf() {
return zxf;
}
public void setZxf(int zxf) {
this.zxf = zxf;
}
public String getBz() {
return bz;
}
public void setBz(String bz) {
this.bz = bz;
}
public byte[] getZp() {
return zp;
}
public void setZp(byte[] zp) {
this.zp = zp;
}
}
Course课程实体类:
package org.vo;
import java.io.Serializable;
public class Course implements Serializable {
private String kch;//课程号
private String kcm;//课程名
private int kkxq;//开课学期
private int xs;//学时
private int xf;//学分
public Course() {
// TODO Auto-generated constructor stub
}
public Course(String kch, String kcm, int kkxq, int xs, int xf) {
this.kch = kch;
this.kcm = kcm;
this.kkxq = kkxq;
this.xs = xs;
this.xf = xf;
}
public String getKch() {
return kch;
}
public void setKch(String kch) {
this.kch = kch;
}
public String getKcm() {
return kcm;
}
public void setKcm(String kcm) {
this.kcm = kcm;
}
public int getKkxq() {
return kkxq;
}
public void setKkxq(int kkxq) {
this.kkxq = kkxq;
}
public int getXs() {
return xs;
}
public void setXs(int xs) {
this.xs = xs;
}
public int getXf() {
return xf;
}
public void setXf(int xf) {
this.xf = xf;
}
}
Score实体类:
package org.vo;
import java.io.Serializable;
public class Score implements Serializable {
private String xh;// 学号
private String kch;// 课程号
private int cj;// 成绩
public Score() {
// TODO Auto-generated constructor stub
}
public Score(String xh, String kch, int cj) {
this.xh = xh;
this.kch = kch;
this.cj = cj;
}
public String getXh() {
return xh;
}
public void setXh(String xh) {
this.xh = xh;
}
public String getKch() {
return kch;
}
public void setKch(String kch) {
this.kch = kch;
}
public int getCj() {
return cj;
}
public void setCj(int cj) {
this.cj = cj;
}
}
DBConn数据连接驱动:
package org.jdbc;
import java.sql.DriverManager;
import com.mysql.jdbc.Connection;
public class DBConn {
private Connection conn=null;
public DBConn(){
this.conn=this.getConnection();
}
public Connection getConnection(){
try{
Class.forName("org.gjt.mm.mysql.Driver");
conn=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/xscj", "root", "1234");
}
catch(Exception e){
e.printStackTrace();
}
return conn;
}
public Connection getConn(){
return conn;
}
}
剩余代码略...................点此处有————详细代码