




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
/軟件學院課程設計報告書課程名稱javaEE課程設計設計題目學生個人成績管理系統(tǒng)專業(yè)班級 學號 姓名 指導教師 2011年12月目錄TOC\o"1-4"\h\z\u1設計時間 22設計目的 23設計任務 33.1任務說明 33.2系統(tǒng)目標 33.3功能要求 34設計內容 44.1界面構建 44.2詳細設計 44.2.1流程設計 44.2.2數(shù)據(jù)庫設計(sqlserver2000) 54.2.3運行調試 64.2.4主要源代碼 85總結與展望 19參考文獻 201設計時間2011.12.122011.12.182設計目的本程序用于用戶對學生成績排名進行簡單的管理,本程序針對于對安全系數(shù)要求不高,操作不是很復雜的小型客戶開發(fā)。本程序可以實現(xiàn)對學生信息的添加、查看、刪除、成績排名等操作,同時支持查看所有課程信息,功能完善,界面簡潔美觀,布局合理,操作簡便,簡單易用,任何人可輕松操作。同時,本程序對系統(tǒng)要求配置較低,運行速度快,而卻對數(shù)據(jù)庫管理要求較低。本程序數(shù)據(jù)庫采用sqlserver2000進行數(shù)據(jù)存儲,該數(shù)據(jù)庫可實現(xiàn)關系較為簡單的數(shù)據(jù)管理。3設計任務3.1任務說明(一)必備功能說明:(1)功能描述:用戶以合法身份登錄系統(tǒng)后,才能進行所有操作;登錄系統(tǒng)時,有兩種權限:管理員權限和學生用戶權限。管理員用戶可以查看所有學生的成績信息(假設只有一門課程),以與對所有學生的成績進行排名;學生用戶可以添加、查看和刪除自己的成績信息。(2)添加學生成績:學生添加成績信息(包括學號、姓名、成績);(3)查看學生成績:管理員可以查看所有學生的成績,學生用戶只能查看自己的成績;(4)刪除成績:學生可以刪除自己的成績;(5)對成績排名:管理員對所有學生成績進行排名。(二)開發(fā)語言與開發(fā)環(huán)境:MyEclipse、Java、數(shù)據(jù)庫(sqlserver2000、mysql、oracle等任選一種)3.2系統(tǒng)目標軟件開發(fā)的意圖便于用戶對學生的管理,方便查看學生的情況。如用戶對學生基本信息進行添加、查看、刪除、成績排名等。3.3功能要求1學生添加自己課程成績的功能2管理員查看所有學生課程成績的功能3學生查看自己課程成績的功能4學生刪除學生課程成績的功能5管理員對成績排名的功能4設計內容4.1界面構建1、為了便于各種操作,軟件采用多頁面的模式。用戶可在不同網(wǎng)頁進行相應操作(錄入、查詢、修改、刪除、顯示所有信息)。2、主頁面(顯示所有信息頁面)是用戶進行各種操作的平臺,具體操作在各個獨立功能頁面中完成。3、主頁面的主要功能位于操作表列中,為進入各個功能窗口的唯一通道。4、當用戶在進行個別錄入、刪除或錯誤輸入操作時,會彈出相應對話框提示用戶。如當錄入成功或刪除成功,彈出成功以與相應的簡明信息提示當,當錄入、刪除失敗以與輸入不當時,彈出錯誤以與簡單的錯誤原因提示用戶重新操作。5、頁面布局盡量合理,各組件位置分布均勻美觀。4.2詳細設計4.2.1流程設計本系統(tǒng)采用struts2框架,用到了和數(shù)據(jù)庫有關的最基本的方法定義,包括增刪改查等。主要Action類與頁面的設計如下:包名類名功能com.actionsAddStudentAction.java添加信息DeleteStudentAction.java刪除信息LoginAction.java登錄驗證ModifyConfirmAction.java確定修改ModifyStudentAction.java修改信息com.beanStudents.javaBean類,包含所有屬性和getters與setterscom.dbDB.java數(shù)據(jù)庫連接類,包含所有和數(shù)據(jù)庫有關的方法定義表1:包與類定義頁面名稱作用login.jsp登錄頁面showStudents.jsp主要操作界面,顯示所有信息和所有操作控件modify.jsp修改頁面Suc.jsp修改成功頁面addStudent.jsp添加頁面表2:頁面設計4.2.2數(shù)據(jù)庫設計(sqlserver2000)表列名類型長度usernamevarchar50passwordvarchar50表3:管理員表設計login圖1.管理員表login4.2.3運行調試圖2.登錄前頁面login.jsp圖3.登錄錯誤界面login.jsp圖4.登錄成功頁面showStudents.jsp圖5.添加學生信息modify.jsp圖6.添加學生信息成功頁面Suc.jsp圖7.刪除學生信息deleteStudent.jsp圖8.對成績進行排序4.2.4主要源代碼1與數(shù)據(jù)庫的連接packagecom.dujie.util;importjava.io.;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.SQLException;importjava.util.Properties;publicclassConnectionUtil{ privatestaticStringdriver; privatestaticStringurl; privatestaticStringuser; privatestaticStringpassword; static{ try{ Propertiespro=newProperties(); InputStreamfis=Connection.class.getClassLoader() .getResourceAsStream("perties"); pro.load(fis); //連接Oracle pro.load(new("jdbc_perties")); //連接MySql// pro.load(new("jdbc_perties"));// pro.load(new("../QueryScore/jdbc_perties"));// driver=pro.getProperty("jdbc.driver");// url=pro.getProperty("jdbc.url");// user=pro.getProperty("jdbc.user");// password=pro.getProperty("jdbc.password"); driver="com.mysql.jdbc.Driver"; url="jdbc:mysql://:3306/queryscore"; user="sa"; password="sa"; Class.forName(driver); }catch(Exceptione){ e.printStackTrace(); } } publicstaticConnectiongetConnection()throwsSQLException{ returnDriverManager.getConnection(url,user,password); } publicstaticvoidmain(String[]args)throwsSQLException{ Connectioncon=ConnectionUtil.getConnection(); System.out.println(con.isClosed()); }}2對數(shù)據(jù)庫內的數(shù)據(jù)查詢packagecom.dujie.dao;importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.util.ArrayList;importcom.dujie.bean.Student;importcom.dujie.util.ConnectionUtil;publicclassStudentDAO{ privatestaticfinalStringSQL_GETBYLOGIN="select*fromuserswhereloginname=?andloginpassword=?"; privatestaticfinalStringSQL_CHANGESCORE="updateuserssetscore=?whereid=?"; privatestaticfinalStringSQL_GETBYID="select*fromuserswhereid=?"; privatestaticfinalStringSQL_GETALL="select*fromuserswherestatus=0andscore>0"; privatestaticfinalStringSQl_SORT="select*fromuserswherestatus=0andscore>0orderbyscoredesc"; publicArrayList<Student>getSort()throwsSQLException{ ArrayList<Student>stuList=newArrayList<Student>(); Connectioncon=null; PreparedStatementps=null; ResultSetrs=null; try{ con=ConnectionUtil.getConnection(); ps=con.prepareStatement(SQl_SORT); rs=ps.executeQuery(); while(rs.next()){ Studentstu=newStudent(); stu.setId(rs.getInt("id")); stu.setName(rs.getString("name")); stu.setScore(rs.getInt("score")); stu.setStuid(rs.getInt("stuid")); stuList.add(stu); } returnstuList; }catch(SQLExceptione){ e.printStackTrace(); throwe; }finally{ rs.close(); ps.close(); con.close(); } } publicArrayList<Student>getAll()throwsSQLException{ ArrayList<Student>stuList=newArrayList<Student>(); Connectioncon=null; PreparedStatementps=null; ResultSetrs=null; try{ con=ConnectionUtil.getConnection(); ps=con.prepareStatement(SQL_GETALL); rs=ps.executeQuery(); while(rs.next()){ Studentstu=newStudent(); stu.setId(rs.getInt("id")); stu.setName(rs.getString("name")); stu.setScore(rs.getInt("score")); stu.setStuid(rs.getInt("stuid")); stuList.add(stu); } returnstuList; }catch(SQLExceptione){ e.printStackTrace(); throwe; }finally{ rs.close(); ps.close(); con.close(); } } publicStudentgetByLogin(StringloginName,StringloginPwd)throwsSQLException{ Connectioncon=null; PreparedStatementps=null; ResultSetrs=null; try{ con=ConnectionUtil.getConnection(); ps=con.prepareStatement(SQL_GETBYLOGIN); ps.setString(1,loginName); ps.setString(2,loginPwd); rs=ps.executeQuery(); while(rs.next()){ Studentstu=newStudent(); stu.setId(rs.getInt("id")); stu.setName(rs.getString("name")); stu.setScore(rs.getInt("score")); stu.setStuid(rs.getInt("stuid")); returnstu; } returnnull; }catch(SQLExceptione){ e.printStackTrace(); throwe; }finally{ rs.close(); ps.close(); con.close(); } } publicbooleanchangeScore(intid,intscore)throwsSQLException{ Connectioncon=null; PreparedStatementps=null; try{ con=ConnectionUtil.getConnection(); ps=con.prepareStatement(SQL_CHANGESCORE); ps.setInt(1,score); ps.setInt(2,id); intresult=ps.executeUpdate(); if(result>0){ returntrue; }else{ returnfalse; } }catch(SQLExceptione){ e.printStackTrace(); throwe; }finally{ ps.close(); con.close(); } } publicStudentgetById(intid)throwsSQLException{ Connectioncon=null; PreparedStatementps=null; ResultSetrs=null; try{ con=ConnectionUtil.getConnection(); ps=con.prepareStatement(SQL_GETBYID); ps.setInt(1,id); rs=ps.executeQuery(); while(rs.next()){ Studentstu=newStudent(); stu.setId(rs.getInt("id")); stu.setName(rs.getString("name")); stu.setScore(rs.getInt("score")); stu.setStuid(rs.getInt("stuid")); returnstu; } returnnull; }catch(SQLExceptione){ e.printStackTrace(); throwe; }finally{ rs.close(); ps.close(); con.close(); } }}3用戶登錄頁面的實現(xiàn)packagecom.dujie.dao;importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.SQLException;importcom.dujie.util.ConnectionUtil;publicclassLoginDAO{ privatestaticfinalStringSQL_CHECK="select*fromuserswhereloginname=?andloginpassword=?"; publicintloginCheck(StringloginName,StringloginPwd)throwsException{ Connectioncon=null; PreparedStatementps=null; ResultSetrs=null; intresult=-1; try{ con=ConnectionUtil.getConnection(); ps=con.prepareStatement(SQL_CHECK); ps.setString(1,loginName); ps.setString(2,loginPwd); rs=ps.executeQuery(); while(rs.next()){ result=rs.getInt("status"); returnresult; } returnresult; }catch(SQLExceptione){ e.printStackTrace(); throwe; }finally{ rs.close(); ps.close(); con.close(); } } publicstaticvoidmain(String[]args)throwsException{ LoginDAOlogin=newLoginDAO(); System.out.println(login.loginCheck("123","123")); }}4JavaBean的實現(xiàn)代表用戶登錄信息的JavaBean類的類名為“Student”該類包含5個私有屬性“id”“name”“score”“stuid”“Id”與其每個屬性的set,get方法。它的實現(xiàn)代碼如下:packagecom.dujie.bean;publicclassStudent{ privateintid; privateStringname; privateintscore; privateintstuid; publicintgetId(){ returnid; } publicvoidsetId(intid){ this.id=id; } publicStringgetName(){ returnname; } publicvoidsetName(Stringname){ =name; } publicintgetScore(){ returnscore; } publicvoidsetScore(intscore){ this.score=score; } publicintgetStuid(){ returnstuid; } publicvoidsetStuid(intstuid){ this.stuid=stuid; } }5Action實現(xiàn)StudentAction:packagecom.dujie.action;importjava.sql.SQLException;importjavax.servlet.http.HttpServletRequest;importorg.apache.struts2.ServletActionContext;importcom.dujie.bean.Student;importcom.dujie.dao.StudentDAO;publicclassStudentAction{ privateStringscore; publicStringchangeScore()throwsNumberFormatException,SQLException{ HttpServletRequestrequest=ServletActionContext.getRequest(); intid=(Integer)request.getSession().getAttribute("id"); StudentDAOstuDAO=newStudentDAO(); System.out.println(score+":"+id); stuDAO.changeScore(id,Integer.parseInt(this.score)); return"changeScore"; } publicStringsort()throwsSQLException{ StudentDAOstuDAO=newStudentDAO(); HttpServletRequestrequest=ServletActionContext.getRequest(); request.getSession().setAttribute("list",stuDAO.getSort()); return"sort"; } publicStringgetScore(){ returnscore; } publicvoidsetScore(Stringscore){ this.score=score; } }Loginactionpackagecom.dujie.action;importjavax.servlet.http.HttpServletRequest;importorg.apache.struts2.ServletActionContext;importcom.dujie.bean.Student;importcom.dujie.dao.LoginDAO;importcom.dujie.dao.StudentDAO;publicclassLoginAction{ privateStringloginName; privateStringpassword; publicStringexecute()throwsException{ LoginDAOloginDAO=newLoginDAO(); StudentDAOstuDAO=newStudentDAO(); System.out.println(this.loginName+":"+this.password); intstate=loginDAO.loginCheck(this.loginName,this.password); if(state==1){ HttpServletRequestrequest=ServletActionContext.getRequest(); request.getSession().setAttribute("list",stuDAO.getAll()); return"admin"; }elseif(state==0){ Studentstu=stuDAO.getByLogin(loginName,password); HttpServletRequestrequest=ServletActionContext.getRequest(); request.getSession().setAttribute("id",stu.getId()); return"student"; }else{ return"failed"; } } publicStringgetLoginName(){ returnloginName; } publicvoidsetLoginName(StringloginName){ this.loginName=loginName; } publicStringgetPassword(){ returnpassword; } publicvoidsetPassword(Stringpassword){ this.password=password; }}6:struts.xml配置:<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEstrutsPUBLIC"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.0//EN"""> <!--STARTSNIPPET:xworkSample--><struts> <packagename="struts"extends="struts-default"namespace="/action"> <actionname="lo
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度家政服務合作協(xié)議書(專業(yè)護理)
- 檢測員相關知識培訓課件
- 二零二五年度景區(qū)景點場地借用安全責任協(xié)議范本
- 二零二五年度臨時工解聘合同及遣散費協(xié)議
- 二零二五年度外貿合同范本:國際貿易結算代理服務協(xié)議
- 領域一情境四招投標與造價咨詢和報送全過程專業(yè)群課件
- 鋰電池材料知識培訓課件
- 講述“活著”的中國法制史知到智慧樹章節(jié)測試課后答案2024年秋曲阜師范大學
- 廣告植入知識培訓課件
- 廣州醫(yī)保知識培訓課件
- 第16課《有為有不為 》課件-2024-2025學年統(tǒng)編版語文七年級下冊
- 第一單元時、分、秒(說課稿)-2024-2025學年三年級上冊數(shù)學人教版
- 地理-浙江省杭州八縣市2024學年高二第一學期期末學業(yè)水平測試試題和答案
- 《康復工程學》課件-第一講 康復工程概論
- DeepSeek:從入門到精通
- 天津2025年天津中德應用技術大學輔導員崗位招聘7人筆試歷年參考題庫附帶答案詳解
- 2025年無錫職業(yè)技術學院高職單招職業(yè)適應性測試近5年??及鎱⒖碱}庫含答案解析
- 2025年銅材拉絲項目可行性研究報告
- 2025四川宜賓市高縣縣屬國企業(yè)第一次招聘3人易考易錯模擬試題(共500題)試卷后附參考答案
- 2024 年國家公務員考試《申論》(地市級)真題及答案
- 南京2025年中國醫(yī)學科學院皮膚病醫(yī)院招聘13人第二批筆試歷年典型考點(頻考版試卷)附帶答案詳解
評論
0/150
提交評論