《jsp简单的学籍管理系统设计方案.doc》由会员分享,可在线阅读,更多相关《jsp简单的学籍管理系统设计方案.doc(17页珍藏版)》请在课桌文档上搜索。
1、完成一个简单的学籍管理系统,具体的要求如下:1、完成数据库与其表的创建2、创建对应的JavaBean3、对数据库的连接单独创建一个类4、在JSP页面完成对应的查询、添加、删除、修改功能。package .bean;public class Student private String stuId;private String stuName;private String stuSex;private int stuAge;private String stuJig;private String stuDept;public String getStuId() return stuId;publ
2、ic void setStuId(String stuId) this.stuId = stuId;public String getStuName() return stuName;public void setStuName(String stuName) this.stuName = stuName;public String getStuSex() return stuSex;public void setStuSex(String stuSex) this.stuSex = stuSex;public int getStuAge() return stuAge;public void
3、 setStuAge(int stuAge) this.stuAge = stuAge;public String getStuJig() return stuJig;public void setStuJig(String stuJig) this.stuJig = stuJig;public String getStuDept() return stuDept;public void setStuDept(String stuDept) this.stuDept = stuDept;package .database;import java.sql.Connection;import ja
4、va.sql.DriverManager;import java.sql.SQLException;public class DBUtil public Connection getConnection()String driver=.microsoft.sqlserver.jdbc.SQLServerDriver;String url=jdbc:sqlserver:/localhost:1433;Databasename=students;String user=webuser;String password=webpass;try Class.forName(driver); catch
5、(ClassNotFoundException e) e.printStackTrace();try return DriverManager.getConnection(url, user, password); catch (SQLException e) e.printStackTrace();return null;public static void main(String args) DBUtil db= new DBUtil();System.out.println(db.getConnection();L学籍管理系统#titletext-align:center;color:#
6、000;font-size:30px; tdtext-align:center; 学籍管理系统 学号某某性别年龄籍贯院系更改删除ahref=change.jsp?xuehao=修改ahref=del.jsp?xuehao=删除添加新记录 I添加记录#titletext-align:center;font-size:30px;color:#000; 添加新记录学号 某某 性别 男女年龄 籍贯 院系 &nb
7、sp; I插入数据0) response.sendRedirect(err.jsp); sql=insert into student(stuId,stuName,stuSex,stuAge,stuJig,stuDept); sql=sql+values(+stuId+,+stuname+,+stusex+,+i+,+stujig+,+stuDept+); stmt.executeUpdate(sql); out.println(正在处理信息,请稍后.); rs.close(); stmt.close(); conn.close(); catch(Except
8、ion e) response.sendRedirect(err.jsp); %修改记录#titletext-align:center;font-size:30px;color:#000; 修改记录formname=form1action=update.jsp?xuehao=method=post学号某某inputtype=textname=stuNamesize=8value=性别 男 女 男 女年龄 inputtype=textname=stuAgesize=2value=籍贯 inpu
9、ttype=textname=stuJgsize=8value=院系 inputtype=textname=stuDeptsize=8value= U修改数据% request.setCharacterEncoding(GB18030); stuId=request.getParameter(xuehao).trim(); out.print(修改成功!); stuname=request.getParameter(stuName).trim(); stusex=request.getParameter(stuSex).tri
10、m();if(stusex.equals(男) stusex=男; elsestusex=女; stuage=request.getParameter(stuAge).trim(); i=Integer.parseInt(stuage); stujig=request.getParameter(stuJg).trim(); stuDept=request.getParameter(stuDept).trim();if(stuname.equals() response.sendRedirect(err.jsp); try DBUtil db=new DBUtil(); conn=db.getC
11、onnection(); stmt=conn.createStatement(); sql=update student set stuName=+stuname+,stuSex=+stusex+,stuAge=+i+,stuJig=+stujig+,stuDept=+stuDept+ where stuId =+stuId+; stmt.executeUpdate(sql); out.println(正在处理信息,请稍后.); stmt.close(); conn.close(); catch(Exception e) response.sendRedirect(err.jsp); %D删除数据%int userID=Integer.parseInt(request.getParameter(xuehao); DBUtil db=new DBUtil(); conn=db.getConnection(); stmt=conn.createStatement(); sql=delete from student where stuId =+userID+; stmt.executeUpdate(sql); out.println(正在处理信息,请稍后.); stmt.close(); conn.close();%调试结果: