好文档 - 专业文书写作范文服务资料分享网站

基于jsp的学生成绩管理系统 - 图文

天下 分享 时间: 加入收藏 我要投稿 点赞

图4.2 添加学生信息页面

publicvoid InsertStudent(String sid,String sname,String smajor,String sclass,String scode) throws Exception{ ;

}

try{

stmt=dbc.getConnection().createStatement(); stmt.executeUpdate(sql); stmt.close(); Statement stmt=null;

DataBaseConnection dbc=null; dbc=new DataBaseConnection();

String sql=\

VALUES('\+sid+\+sname+\+smajor+\+sclass+\+scode+\

}catch (Exception e){

thrownew Exception(\插入中出现错误!!!\); }finally { }

dbc.close();

2.删除学生信息

图4.3 删除学生信息页面

publicvoid DeletebyID(String sid) throws Exception{

String sql=\+sid+\; Statement stmt=null;

DataBaseConnection dbc=null; dbc=new DataBaseConnection(); try{

stmt=dbc.getConnection().createStatement(); stmt.executeUpdate(sql); stmt.close();

}catch (Exception e){

thrownew Exception(\删除中出现错误!!!\); }finally { }

}

dbc.close();

3.查询学生信息

图4.4 查询学生信息页面

publicVector Select(String sid,String sclass,String smajor)throws Exception{

Vector all=newVector();

String sql1=\; String sql=null; if(sid!=\) {

sql=sql1+\+sid+\; if(sclass!=\) { }

sql=sql+\+sclass+\;

}

if(smajor!=\) { }

sql=sql+\+smajor+\;

else { }

sql=sql+\; Statement stmt=null;

DataBaseConnection dbc=null; dbc=new DataBaseConnection(); try{

stmt = dbc.getConnection().createStatement(); ResultSet rs = stmt.executeQuery(sql); while(rs.next()) {

Student stu=new Student(); stu.setSid(rs.getString(\)); stu.setSname(rs.getString(\)); stu.setSmajor(rs.getString(\)); stu.setSclass(rs.getString(\)); stu.setTcredit(rs.getDouble(\)); stu.setTcreditjd(rs.getDouble(\)); stu.setOcredit(rs.getDouble(\)); stu.setAcredit(rs.getDouble(\)); if(sclass!=\) { } else { }

if(smajor!=\) { } else { }

sql=\;

sql=sql1+\+smajor+\; sql=sql1+\+sclass+\; if(smajor!=\) { }

sql=sql+\+smajor+\;

stu.setEgrade(rs.getDouble(\)); stu.setMajorpm(rs.getInt(\)); stu.setClasspm(rs.getInt(\)); stu.setScode(rs.getString(\)); all.addElement(stu);

}

rs.close();

stmt.close();

} catch (Exception e) {

thrownew Exception(\查询中出现错误!!!\); } finally { dbc.close();

}

return all;

}

public String SelectBySid(String sid) throws Exception{ String sname=null;

String sql=\+sid+ \; Statement stmt=null;

DataBaseConnection dbc=null; dbc=new DataBaseConnection(); try { stmt=dbc.getConnection().createStatement(); ResultSet rs=stmt.executeQuery(sql); while(rs.next()){

sname=rs.getString(\);

}

rs.close(); stmt.close();

} catch (Exception e) {

// TODO: handle exception

thrownew Exception(\查询中出错!!!\); }finally{ dbc.close();

}

return sname;

4.修改学生信息

}

图4.5 修改学生信息页面

publicvoid UpdatebyID(String sid,String sname,String smajor,String sclass,String scode) throws Exception{

String sql=\

sname='\+sname+\+smajor+\+sclass+\+scode+\+sid+\;

Statement stmt=null;

DataBaseConnection dbc=null; dbc=new DataBaseConnection(); try{

stmt=dbc.getConnection().createStatement(); stmt.executeUpdate(sql); stmt.close();

}catch (Exception e){

thrownew Exception(\修改中出现错误!!!\); }finally { }

}

dbc.close();

5.查看留言

2hqxn34jix6rgfl162a4
领取福利

微信扫码领取福利

微信扫码分享