您好,欢迎来到年旅网。
搜索
您的当前位置:首页网上报名系统开发案例实训报告

网上报名系统开发案例实训报告

来源:年旅网
网上报名系统开发案例

三层架构设计与实现分为:

1.数据访问层 2.业务逻辑层 3.控制器

三个模块

(1).考生报名模块 (2).考生登录模块 (3).修改密码模块设计 package ; import .*; import .*;

public class DBAccess {

private Connection conn = null;

private Statement stmt = null;

private ResultSet rs = null;

private PreparedStatement prpSql=null;

public DBAccess() {} /**

* 返回一个数据库连接 * @return Connection

*/ public Connection

getConn() {

if (conn == null) {

getConnection();

}

return conn; }

/**

* 加载MySQL驱动 * 函数功能:获得连接对象,Statement对象

*/

public void

databaseDriver()

{

try{ (\"\");

}

catch(Exception

e){}

} public void

getConnection() { databaseDriver();

try {

conn=(\"jdbc:\000000\");

stmt=(); ;

import .*; public class examineeBll {

/**添加考生数据的方法**/

public

int

if(!((c<='z'&&c>='a')| \"身份证号或密

|(c<='Z')&&

码不符合要 CreateExaminee(String examID,String

examName,String sex,

String

company,String address,String

phone,String email,

String

password,String examType,String

memo,String pic){

examineeDal

examDal=new examineeDal();

int result=0;

if(()==12||()==18)

&&()>0){

boolean

isLD=true;

for(int

i=0;i<();i++){

char

c=(i);

(c>='A')||(c<='9')&&(c>='0'

))){

isLD=false;

}

}

if(isLD==true

&&

(examID)!=null){

return

result=-2;

}

if(isLD==true){

result=

(examID,

examName,

sex,

company, address, phone, email, password,

examType, memo, pic);

} }

else{ 求!\");

\"函数返回值:

\"+result); }

return result;

}

/**考生登录方法***/

public

int

examineeLogin(String examID,String password){

examineeDal

examDal=new examineeDal(); int result=0;

if(()==12||()==18)

&&()>0){

examinee

exam=null;

exam=(examID,

password);

if(exam!=null){ catch(Exception ne){

result=1; } else{

result=-1; }

}

return result;

}

/**储存照片文件名**/

public

int

setExamineePic(String examID,String picStr){

examineeDal

examDal=new examineeDal();

repareStatement

(str);

(1,

examID);

(2,

password);

ResultSet

rst=(prpSql);

if(rst!=null&&()){

exam=new examinee

(1),(2),

(3),(4),(5),

(6),(7),(8),

(9),(10),(11)

); }

if(prpSql!=null){

();

prpSql=null; }

}

}

\"examineedal:getexamineebyIDPwd发生错误\");

}

finally{ ();

}

return exam;

}

/**函数功能修改用户密码*@return 成功返回1,否则返回*/

public

int

setExaminePwd(String examID,String newPassword){

DBAccess

dba=new

DBAccess(); int result=0; try{ if()!=null){

PreparedStatement prpSql;

String

strSql=\"Update examinee set

password=? where id=?\";

prpSql=().prepareStatement

(strSql);

(1,

}

/**修改考生信息*@return影响行数,失败0 */

=?,where id=?\"; ment

prpSql=().prepareState

newPassword);

(2,

public int

examID);

result=(prpSql);

if(prpSql!=null){ ();

prpSql=null; }

}

}catch(Exception

ne){

\"exmaineedal:setPassword发生 错误\");

result=-1;

} finally{ (); }

return result;

updateExamineeByID(String examID,String

examName,String sex,String company,String address,String

phone,String

email,String

examType,String memo){

DBAccess

dba=new

DBAccess(); int result=0; try{

if()!=null){

PreparedStatement

prpSql;

String

strSql=\"update examinee set

name=?,sex=?,company=?,\"+\"address=?,phone=?,email=?,examType=?,memo

(strSql);

(1,examName);

(2, sex); (3, company); (4, address); (5, phone); (6, email);

(7, examType); (8, memo);

(9, examID);

if(prpSql!=null){

();

prpSql=null;

}

}

}

catch(Exception ne){ ();

return

-1;

} finally{ ();

}

return result; }

/**设置图片文件名*@param examID

*@param

picStr

*@return 成功1, 失败0*/ public

int

setExamineePic(String examID ,String picStr){

DBAccess

dba=new

DBAccess();

int result=0;

try{ if()!=null){

String

strSql=\"update examinee set

pic='\"+picStr+\"'

where

id='\"+examID+\"'\";

result=(strSql);

}

}catch(Exception

ne){ \"发生异常\"+ne); (); }

finally{

();

}

return result; }

/**按身份证号删除考生*@param examID*@return 1成功,0失败,出现异 常*/

public

int

deleteExmineeByID(String examID){

DBAccess

dba=new

DBAccess();

int result=0;

try{

if()!=null){

PreparedStatement prpSql;

String

strSql=\"delete from examinee

where id=?\";

prpSql=().prepareStatement

(strSql);

(1,

examID); result=();

if(prpSql!=null){ ();

prpSql=null; }

}

}catch(Exception

ne){

();

return -1; }

finally{

}

}

();

/**

* Destruction of the

public void

doGet(HttpServletRequest request,

*/

HttpServletResponse

public void destroy() {

servlet.

return result;

}

package ;

import .*; import .*; import .*;

import class HandleLogin extends HttpServlet {

public

String

handleString(String s){

try{

byte

bb[]=(\"iso-8859-1\");

s=new

String(bb);

}catch(Exception

ee){}

return s;

}

public HandleLogin() { super(); }

();

*

* This method is called

when a form has its tag value

method equals to get.

*

* @param request the request send by the client to the

server

* @param response the

response send by the server to the client

*

@throws

ServletException if an error occurred

* @throws IOException

if an error occurred

*/

response)

throws

ServletException, IOException {

(\"text/html\");

PrintWriter out =

();

(\"HTML

PUBLIC \\\"-

*

* This method is called when a form has its tag value

method equals to post. *

* @param request the

request send by the client to the

server

* @param response the response send by the server to the

client

log=new examineeBll

loginBean();

*

@throws

ServletException if an error occurred

* @throws IOException

}

(\"login\

exambll=new examineeBll();

int

log); result=(loginName,

password); }catch(Exception

if an error occurred */

public

void

doPost(HttpServletRequest request,

HttpServletResponse response)

throws

ServletException, IOException {

loginBean

log=null;

String

backMessage=\"\";

HttpSession

session=(true); try{

log=(loginBean)

(\"login\");

if(log==null){ ee){

log=new loginBean();

(\"login\

log);}

String loginName=

(\"loginName\").trim(),

password=

(\"password\").trim();

loginName=handleString

(loginName); boolean ok=(); if(ok==true&&())){

backMessage=\"

已经登录\";

(backMessage);

}

else{

if(result==1){

backMessage=\"登陆成功

\";

(backMessage);

(true);

(loginName);

}

else

if(result==0){

backMessage=\"您输入的

身份证号或密码

不符合要求!\";

(backMessage);

(false);

(loginName);

(password); }

else{

backMessage=\"您输入的

身份证号不存在

或密码不正确!\";

(backMessage);

(false);

(loginName);

(password); }

}

RequestDispatcher

dispatcher=(\"\");

(request,

response);

}

public

void

init(ServletConfig config) throws

ServletException {

();

} } package ;

import .*; import .*;

import .*;

import class HandleModifPwd extends HttpServlet {

/**

* Constructor of the

object. */

public HandleModifPwd()

{ super();

}

/**

* Destruction of the

servlet.

*/

public void destroy() { ();

*

* This method is called

when a form has its tag value method equals to get. *

* @param request the

request send by the client to the server

* @param response the

response send by the server to the client

*

@throws

ServletException if an error occurred

* @throws IOException

if an error occurred

*/

public

void

doGet(HttpServletRequest request, HttpServletResponse response)

throws

ServletException, IOException {

doPost(request,

response);

/**

* The doPost method of }

HttpSession loginBean

session=(true);

loginBean

log=(loginBean)(\"login\");

String

log=(loginBean)(\"login\");

if(log==null){ loginName=();

passwordBean

pwd=new passwordBean(); the servlet.
*

* This method is called

when a form has its tag value method equals to post. *

* @param request the

request send by the client to the server

* @param response the

response send by the server to the client

*

@throws

ServletException if an error occurred

* @throws IOException

if an error occurred */

public

void

doPost(HttpServletRequest request, HttpServletResponse response)

throws

ServletException, IOException {

(\"\");

} else{

modifyPassword(request

,response);

}

}

public void

modifyPassword(HttpServletRequest request,

HttpServletResponse

response)throws

ServletException,IOException {

HttpSession

session=(true);

(\"password\

String

oldPassword=(\"oldPassword\");

String

newPassword=(\"newPassword\");

examineeBll

exambll=new examineeBll();

int

result=(loginName, newPassword, oldPassword); if(result==0){

(\"密码不符合

要求,未更新!\");

}else

if(result==-1){

(\"旧密码不正

确,密码更新失败!\"); } else{

(\"更新成功!

\");

(newPassword);

(oldPassword);

import .*; import .*;

import class HandleRegister

examName=(\"examName\").

trim(),

void

sex=(\"sex\").trim(),

}

RequestDispatcher

extends HttpServlet{

public

dispatcher=(\"\");

(request,

response);

}

/**

* Initialization of the servlet.
*

*

@throws

ServletException if an error occurs

*/

public

void

init(ServletConfig config) throws ServletException { (config);

}

} package ;

init(ServletConfig config)throws ServletException{

(config);

}

public

String

handleString(String s){

try{

byte

bb[]=(\"UTF-8\"); s=new String(bb);

}

catch(Exception ee){ return s;

}

public

void

doPost(HttpServletRequest request,HttpServletResponse response)throws

ServletException,IOException{

registerBean

reg=new registerBean(); (\"register\

String

examID=(\"examID\").trim(),

company=(\"company\").trim(),

address=(\"address\").tr

im(), phone=(\"phone\").trim()

,

email=(\"email\").trim(),

examType=(\"examType\").

trim(),

memo=(\"memo\").trim(),

password=(\"password\").

trim(), pic=\"\

backMessage=\"\"; int result=0; try{

examineeBll

exambll=new examineeBll();

result=(examID,

sex, phone,

company, email,

);

(backMessage);

}

RequestDispatcher

examName, address,

dispatcher=(\"\"); password, examType, memo, pic); if (result==0){

backMessage=\"

身份证号或密码不符合要求!请重新报考!\";

(backMessage); }

if(result==-1){

backMessage=\"

数据库访问发生错误!\";

(backMessage); }

if(result==-2){

backMessage=\"

身份证号已存在!\";

(backMessage); }

if(result==1){

backMessage=\"

报名成功!\";

(handleString(address)

(handleString(company)

);

(email);

(handleString(examName

)); (examID);

(handleString(examType

));

(handleString(memo));

(password);

(phone);

(pic);

(handleString(sex));

} }

catch(Exception

ex){

backMessage=\"发生

错误!\"+();

(backMessage);

(request,response);

}

public

void

doGet(HttpServletRequest request,HttpServletResponse response)throws

ServletException,IOExceptio

n{ doPost(request,respons

e);

}

}

package ;

public class loginBean {

String

loginName,password,backMessage; boolean success=false;

public

String

getLoginName() {

return loginName;

}

public

void

setLoginName(String

loginName) {

} public

String

= loginName;

}

}

= success;

}

public

void

setPassword(String password) { = password;

}

public

String

getBackMessage() {

return

backMessage;

}

public

void

setBackMessage(String backMessage) {

= backMessage;

}

public

boolean

isSuccess() {

return success;

}

public

void

setSuccess(boolean success) {

public

class

modifyMessageBean {

private String examID =

null;\"

pageEncoding=\"ISO-8859-1\"%>

<%

String path = ();

String basePath = ()+\":

<%@ page language=\"java\" import=\".*\"

pageEncoding=\"GBK\"%>

<%

String path = ();

String basePath = ()+\":\" pageEncoding=\"GBK\"%>

<%@ page import=\".*\" %>

id=\"login\"

type=\"\" scope=\"session\"/>

pageEncoding=\"GBK\"%>

<%@ page import=\"\" %>

<%

String path = ();

String basePath = ()+\":\"

pageEncoding=\"utf-8\"%> <%@ page import=\".*\" %>

pageEncoding=\"gb2312\"%> <%@ page import=\"\" %> <%@ page import=\"\" %> <%@ page import=\"\" %>

<%@ page import=\".*\" %> <%@ page import=\".*\" %> <%@ page import=\"\" %> HTML

PUBLIC

\"-//W3C//DTD Transitional//EN\">

HTML DataSource!\");

} }

catch(Exception ne)

My JSP '' starting (\"<br>\");<p>String<p>{<p>str=\"select * from examinee\"; page 1234 <%

DBAccess dba=new

DBAccess();

examineeDal

examd=new examineeDal(); ArrayList list=new

ArrayList(); try{

int rsult= (\"5\高大上\男\河北农大\保定市领域四杰\

\"3\高级\计算机类\框框\"); (rsult);

();

if()!=null) {

(\"已经获得

ResultSet rst=(str);//

从一个已存在的表中读取数据

(\"以下是

从数据库中读取出来的数据:
\");

while()){ (\"
\"); (1));}

}

(\"
系统 时间:\"+());

examinee exambean=null; exambean=(\"567\"); (\"

\"+());

list=();

for(examinee e:list){ (\"
这是通过ArrayList得到的值:\"+());

(\"出现如下错误:
\"); (ne); } finally{ ();

(\"
已经关闭DataSource!\");

} %>

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- oldu.cn 版权所有 浙ICP备2024123271号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务