山东建筑大学
Java课程设计报告设计题目 电话号码查询系统
学号 2010121187专业班级信计101
指导教师 王文
1、设计目的
1、通过JAVA课程设计使大家能够将学到的面向对象的设计思想运用在具体工
作和学习中加深对类和对象的理解要求学生对生活中许多具体的事物抽象
出类。
2、通过这次课程设计掌握JAVA的编程思想为后续设计编程打下基础。
3、培养实际操作能力和实践能力为以后的工作打下坚实的基础。
2、总体设计
3、详细设计homework\src\com\work为工作空间bean文件夹下的TelBean.java为Bean类operate文件夹下的TelOperate.java为服务器接收信息端可以对所获取的信息进行相应的方法调用。 Te l Sq l .j a va对数据库中的数据进行增删改查。
sql文件夹下Conn.java为对数据库提供驱动加载等操作。
addInfo.jsp为添加信息页面截图中有相应的运行图index.jsp为首页页面信息l istInfo.jsp为查询之后显示信息的页面searchInfo.jsp为查询条件选择页面
4、调试与测试
调试中部分功能的测试结果及截图
1、 电话管理功能列表
2、添加电话号码
添加成功
3、 显示所有电话号码信息
4、 按姓名查询功能及查询结果
查询结果
5、按电话号码查询功能及查询结果
查询结果
6、按部门查询
5、源程序清单和执行结果ifexists(select*fromdbo.sysobjectswhereid=object_id(N' [dbo] .[search]')andOBJECTPROPERTY(id,N' Is UserTa ble')=1)droptable[dbo] .[search]
GO
CREATETABLE[dbo] .[search] (
[name] [nvarchar](20)COLLATEChinese_PRC_CI_ASNOTNULL,
[tel] [varchar](11)COLLATEChinese_PRC_CI_ASNULL,
[dep] [nvarchar](20)COLLATEChinese_PRC_CI_ASNULL
)ON[PRIMARY]
GO
Beanpackagecom.work.bean;
publ icclassTelBean{privateStringname;privateStringtel;privateStringdep;publ icStringgetName(){returnna me;
}publ icvoidsetName(Stringname){this.name=name;
}publ icStringgetTel(){retu rntel;
}publ icvoidsetTel(Stringtel){this.tel=tel;
}publ icStringgetDep(){returndep;
}publ icvoidsetDep(Stringdep){this.dep=dep;
}
}
Operate
Teloperatepackagecom.work.operate;importjava. io. IOException;importjava. io.PrintWriter;importjava.net.URLDecoder;importjava.uti l .ArrayList;importjavax.servlet.ServletException;
importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importcom.work.bean.TelBean;publ icclassTelOperateextendsHttpServlet{
**
*ThedoGetmethodoftheservlet.<br>
*
*Thismethodiscal ledwhenaformhasitstagvaluemethodequalstoget.
*
*@paramrequesttherequestsendbythecl ienttotheserver
*@paramresponsetheresponsesendbytheservertothecl ient
*@throwsServletExceptionifanerroroccurred
*@throwsIOExceptionifanerroroccurred
*/publ icvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException, IOException{request.setCharacterEncoding("utf-8");response.setCharacterEncoding("utf-8");
//初始化
PrintWriterpw=response.getWriter();
Stringtype=request.getParameter("type");
Stringname=request.getParameter("username");
Stringtel=request.getParameter("tel");
Stringdep=request.getParameter("dep");
TelSqltelSql=newTelSql();
//根据出入type判断操作方式if(type.equals("search")){
//根据条件查询
ArrayList<TelBean>searchList=telSql .geTelListByInfo(name,tel,dep);request.getSession().setAttribute("l istRes ult",searchList);request.getRequestDispatcher("l istInfo.jsp").forward(request,response);}elseif(type.equals("add")){
//添加if(telSql .addTel Info(name,tel,dep))pw.print("true");else
pw.print("false");
}elseif(type.equals("l ist")){
//列表
ArrayList<TelBean>displayList=telSql .geTelList();request.getSession().setAttribute("l istResult",displayList);request.getRequestDispatcher("l istInfo.jsp").forward(request,response);}elseif(type.equals("del")){
//删除指定信息telSql .delTel Info(name);
ArrayList<TelBean>displayList=telSql .geTelList();request.getSession().setAttribute("l istResult",displayList);request.getRequestDispatcher("l istInfo.jsp").forward(request,response);}
}
**
*ThedoPostmethodoftheservlet.<br>
*
*Thismethodiscal ledwhenaformhasitstagvaluemethodequalstopost.
*
*@paramrequesttherequestsendbythecl ienttotheserver
*@paramresponsetheresponsesendbytheservertothecl ient
*@throwsServletExceptionifanerroroccurred
*@throwsIOExceptionifanerroroccurred
*/publ icvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException, IOException{this.doGet(request,response);
}
}
Telsqlpackagecom.work.operate;importjava.sql .*;importjava.uti l .*;importcom.work.bean.*;importcom.work.sql .*;
每年的7月的最后一个周五是全球性质的“系统管理员日”,据说是为了感谢系统管理员的辛苦工作....friendhosting决定从现在开始一直到9月8日对其全球9个数据中心的VPS进行4.5折(优惠55%)大促销。所有VPS基于KVM虚拟,给100M带宽,不限制流量,允许自定义上传ISO...官方网站:https://friendhosting.net比特币、信用卡、PayPal、支付宝、微信、we...
百驰云成立于2017年,是一家新国人IDC商家,且正规持证IDC/ISP/CDN,商家主要提供数据中心基础服务、互联网业务解决方案,及专属服务器租用、云服务器、云虚拟主机、专属服务器托管、带宽租用等产品和服务。百驰云提供源自大陆、香港、韩国和美国等地骨干级机房优质资源,包括BGP国际多线网络,CN2点对点直连带宽以及国际顶尖品牌硬件。专注为个人开发者用户,中小型,大型企业用户提供一站式核心网络云端...
LetBox此次促销依然是AMD Ryzen处理器+NVME硬盘+HDD大硬盘,以前是5TB月流量,现在免费升级到10TB月流量。另外还有返余额的活动,如果月付,月付多少返多少;如果季付或者半年付,返25%;如果年付,返10%。依然全部KVM虚拟化,可自定义ISO系统。需要大硬盘vps、大流量vps、便宜AMD VPS的朋友不要错过了。不过LetBox对帐号审核严格,最好注册邮箱和paypal帐号...