javaEE衡量生活質(zhì)量課程設(shè)計報告_第1頁
javaEE衡量生活質(zhì)量課程設(shè)計報告_第2頁
javaEE衡量生活質(zhì)量課程設(shè)計報告_第3頁
javaEE衡量生活質(zhì)量課程設(shè)計報告_第4頁
javaEE衡量生活質(zhì)量課程設(shè)計報告_第5頁
已閱讀5頁,還剩11頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、.PAGE :.; 設(shè)計時間年月日月日 設(shè)計目的JavaEE課程設(shè)計是對所學(xué)JavaEE與中間件課程的小結(jié),是提高學(xué)生對所學(xué)知識綜合運用才干的一種方式,是集中實際性環(huán)節(jié)之一。要求同窗們對課程中所學(xué)習(xí)到的知識綜合運用,開發(fā)有一定規(guī)模的Java Web程序。設(shè)計義務(wù)設(shè)計生活質(zhì)量衡量系統(tǒng)衡量規(guī)范闡明:消費有兩種支出:吃飯支出和 其它支出,假設(shè)在一段時間內(nèi),吃飯支出占總支出的比例超越%,生活質(zhì)量為貧困;假設(shè)在-%之間,為溫飽;假設(shè)低于%,生活質(zhì)量為小康。功能描畫:用戶以合法身份登錄系統(tǒng)后,才干進展一切操作;用戶可以添加、查看和刪除支出情況支出類型有兩種:吃飯支出和其它支出、額度人民幣、日期。添加支出情

2、況查看支出情況刪除支出情況統(tǒng)計在某個時間段內(nèi),生活質(zhì)量屬于哪個層次 設(shè)計內(nèi)容 . 設(shè)計標(biāo)題生活質(zhì)量衡量系統(tǒng)。 .系統(tǒng)功能要求用只需擁有合法身份才干登錄系統(tǒng),用以合法身份登錄后才干進展添加、查看和刪除支出情況支出類型有兩種:吃飯支出和其它支出、額度人民幣、日期。. 數(shù)據(jù)庫存儲要求 數(shù)據(jù)的存儲要求:吃飯支出其他支出,日期。.數(shù)據(jù)庫的設(shè)計圖 數(shù)據(jù)庫存儲表圖數(shù)據(jù)庫存儲數(shù)據(jù).系統(tǒng)構(gòu)造關(guān)系 登陸窗口密碼noyes操作界面計算刪除插入查詢 圖jsp頁面構(gòu)造Jsp頁面?zhèn)魉蛥?shù)調(diào)用servlet類參數(shù)計算方法servlet刪除方法servlet查詢方法servlet插入方法servlet刪除方法dao類查詢方法

3、dao類插入方法dao類計算方法dao類圖Java類功能調(diào)用. Jsp 頁面設(shè)計.登錄界面圖登錄界面代碼如下: 歡迎登陸生活質(zhì)量衡量系統(tǒng)! 用戶稱號: 用戶密碼: .登錄勝利界面 圖登錄勝利查詢界面 登陸勝利!點擊獲得詳細(xì)的信息 .查詢結(jié)果界面圖查詢結(jié)果界面.Java方法設(shè)計.Servlet類密碼驗證的Servlet類的代碼如下:public class LoginServlet extends HttpServlet public void doGet(HttpServletRequest request, HttpServletResponse response)throws Servle

4、tException, IOException doPost(request,response);public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException String username = (String)request.getParameter(username);String userpsw = (String)request.getParameter(userpsw);System.out.println(usernam

5、e);String forward = ;if(username.equals() & userpsw.equals()forward = /success.jsp;elseforward = /error.jsp; 顯示一切信息的servlet類代碼設(shè)計如下:public class ListAllThingServlet extends HttpServlet public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doPo

6、st(request,response);public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException ThingDAO thingDAO=new ThingDAO();List list=thingDAO.getAllThing();request.setAttribute(allthing, list);request.getRequestDispatcher(/showAllThing.jsp).forward(request

7、, response);控制增刪改操作的servlet類代碼設(shè)計如下:插入支出情況代碼:public class SaveOutServlet extends HttpServlet public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doPost(request,response);public void doPost(HttpServletRequest request, HttpServletResponse resp

8、onse)throws ServletException, IOException double x=.; double y=.; x=Double.parseDouble(request.getParameter(eating); y=Double.parseDouble(request.getParameter(others); String times=(String)request.getParameter(times); ThingDAO thingDAO=new ThingDAO(); try thingDAO.saveUser(x,y,times); catch(Exceptio

9、n e) e.printStackTrace(); List list=thingDAO.getAllThing();request.setAttribute(allthing, list);request.getRequestDispatcher(/showAllThing.jsp).forward(request, response);刪除支出情況代碼:public class DeleteOutServlet extends HttpServlet public void doGet(HttpServletRequest request, HttpServletResponse resp

10、onse)throws ServletException, IOException doPost(request,response);public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException double x=.; x=Double.parseDouble(request.getParameter(eating);ThingDAO thingDAO=new ThingDAO();try thingDAO.deleteUser(x

11、);catch(Exception e)e.printStackTrace();List list=thingDAO.getAllThing();request.setAttribute(allthing, list);request.getRequestDispatcher(/showAllThing.jsp).forward(request, response);衡量生活質(zhì)量代碼:public class Caculate extends HttpServlet public void doGet(HttpServletRequest request, HttpServletRespons

12、e response)throws ServletException, IOException doPost(request,response);public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException String time=request.getParameter(time); String time=request.getParameter(time); ThingDAO thingDAO=new ThingDAO();

13、try String resulte=thingDAO.caculate(time, time); request.setAttribute(resulte, resulte);request.getRequestDispatcher(/caculateresulte.jsp).forward(request,response); catch(Exception e) e.printStackTrace(); .Dao類顯示一切支出情況的Dao類代碼設(shè)計如下:public class ThingDAO public List getAllThing()Connection con=DBConn

14、ection.getConnection();List list=new ArrayList();tryStatement ps=con.createStatement();/Statement(select * from moneying);ResultSet rs=ps.executeQuery(select * from moneying);while(rs.next()Thing thing=new Thing();thing.setEating(rs.getDouble();thing.setOthers(rs.getDouble();thing.setTimes(rs.getStr

15、ing();list.add(thing);return list;catch(SQLException e)e.printStackTrace();finallyif(con!=null)trycon.close();catch(SQLException e)e.printStackTrace();return list;添加,刪除和統(tǒng)計生活質(zhì)量的Dao類代碼設(shè)計如下:public boolean saveUser(double m, double n,String q) throws ExceptionConnection con = DBConnection.getConnection(

16、);String listSQL=insert into moneying values (?,?,?);PreparedStatement pstmt=con.prepareStatement(listSQL);trypstmt.setDouble(, m);pstmt.setDouble(, n);pstmt.setString(, q);pstmt.executeUpdate();conmit();return true;catch (SQLException e)con.rollback();e.printStackTrace();finallycon.close();return f

17、alse;public boolean deleteUser(double x)throws ExceptionConnection con=DBConnection.getConnection(); PreparedStatement pstmt=con.prepareStatement(delete from moneying where eating=?); try pstmt.setDouble(, x); pstmt.executeUpdate(); conmit(); return true; catch(SQLException e) con.rollback(); e.prin

18、tStackTrace(); finally con.close(); return false; public String caculate(String x,String x)/計算式溫飽還是小康生活程度Connection con=DBConnection.getConnection();int i=;int j=;String SQL=select id from moneying where times=x;String SQL=select id from moneying where times=x;tryPreparedStatement psmt=con.prepareSt

19、atement(SQL);PreparedStatement psmt=con.prepareStatement(SQL);ResultSet rs=psmt.executeQuery();ResultSet rs=psmt.executeQuery();if(rs.next()i=rs.getInt();if(rs.next()j=rs.getInt();catch(SQLException e)e.printStackTrace();double eatingtotal=.;double total=.;int k=;for(k=i;k=j;k+)String SQL=seclect ea

20、ting,others from moneying where id=k;tryPreparedStatement psmt=con.prepareStatement(SQL);ResultSet rs=psmt.executeQuery();eatingtotal=eatingtotal+rs.getDouble();total=total+rs.getDouble()+rs.getDouble();catch(SQLException e)e.printStackTrace();if(eatingtotal/total.)return pinkun;elsereturnwenbao;.數(shù)據(jù)

21、庫銜接類數(shù)據(jù)庫銜接代碼如下:public class DBConnection public static Connection getConnection()final String driverName=com.microsoft.jdbc.sqlserver.SQLServerDriver;final String url=jdbc:microsoft:sqlserverlocalhost:;databasename=mydb;tryClass.forName(driverName);catch(ClassNotFoundException e)e.printStackTrace();tryConnection con=Driver

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論