




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、项目构思使用JDBC技术连接MySQL数据库,实现对图书管理系统中图书信息的浏览,增加,修改,删除功能。项目设计1,安装并配置数据库,创建数据库,创建表及添加数据2程序设计1 文件名:index.jsp 图书管理系统 添加图书信息 书名作者价格管理 % Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(jdbc:mysql:/localhost:3307/school,root,ylx); Statement stmt = con.createStatement(); Strin
2、g s = Select * FROM book; ResultSet rs = stmt.executeQuery(s); while(rs.next() int id=rs.getInt(1); out.println(+rs.getString(2)+rs.getString(3)+rs.getString(4)+修改 删除); rs.close(); stmt.close(); con.close(); % 2文件名:add.jsp 添加图书信息添加图书信息 书名: 作者: 价格: 元 %request.setCharacterEncoding(UTF-8);String s
3、ubmit=request.getParameter(submit);if(submit!=null&!submit.equals() String bookname=request.getParameter(bookname); String author=request.getParameter(author); String price=request.getParameter(price); Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(jdbc:mysql:/loc
4、alhost:3307/school,root,ylx); Statement stmt = con.createStatement(); String sql=insert into book(bookname,author,price) values(+bookname+,+author+,+price+); int i=stmt.executeUpdate(sql); if(i=1) out.println(alert(添加成功,单击确定跳转到主页!);); response.setHeader(refresh,1;url=index.jsp); else out.println(ale
5、rt(添加失败,单击确定返回添加页面!),); response.setHeader(refresh,1;url=add.jsp); stmt.close(); con.close();%3文件名edit.jsp 修改图书信息 修改图书信息 书名: input name=bookname type=text value= 作者: input name=author type=text value= 价格: input name=price type=text value=元 input type=hidden name=id value= 4文件名:update.jsp 修改完成 % requ
6、est.setCharacterEncoding(UTF-8); String bookname=request.getParameter(bookname); String author=request.getParameter(author); String price=request.getParameter(price); String id=request.getParameter(id); Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(jdbc:mysql:/lo
7、calhost:3307/school,root,ylx); Statement stmt = con.createStatement(); String sql=update book set bookname=+bookname+,author=+author+,price=+price+ where id=+id; int i=stmt.executeUpdate(sql); if(i=1) out.println(alert(修改成功,单击确定后自动跳转到主页!);); response.setHeader(refresh,1;url=index.jsp); stmt.close();
8、 con.close(); % 5文件名:del.jsp 删除图书信息 % request.setCharacterEncoding(gb2312); Class.forName(com.mysql.jdbc.Driver); Connection con = DriverManager.getConnection(jdbc:mysql:/localhost:3307/school,root,ylx); Statement stmt = con.createStatement(); String id=request.getParameter(id); int i=stmt.executeUpdate(delete from book where id=+id); if(i=1) out.println(alert(删除成功,单击确定后自动跳转到主页!);); response.setHeader(refresh,1;url=index.jsp); else out.println(alert(删除失败,单击确定后自动跳转到主页!);); response.setHeader(refresh,1;url=index.jsp); co
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 大专入学试卷题目及答案
- 大暑节气养生题目及答案
- 2025年低碳城市建设规划与吉林案例分析报告
- 河南省豫建安c证考试试题及答案
- 江苏省保安员考试试题及答案
- 建筑安全员b证考试考试试题及答案
- 2025年长春市事业单位公开招聘工作人员(含专项招聘高校毕业生)公主岭地区复审笔试历年典型考题及考点剖析附带答案详解
- 安全主任考试试题及答案
- 重庆市安全员c证考试试题及答案
- 文化创意产业园厂房转租及知识产权保护合同
- 老旧小区路灯改造施工方案
- 《大学生社交礼仪》课件
- DB11∕T 1772-2020 地源热泵系统评价技术规范
- 电瓶车以租代购协议书范文范本
- 契约恋爱协议书范本范本电子版
- 2023医疗质量安全核心制度要点释义(第二版)对比版
- 2022年广西百色市中考物理试题(含答案解析)
- 2024年服装辅料项目可行性研究报告
- 四川省2024年中考生物试卷十二套合卷【附答案】
- 呼吸机雾化吸入疗法护理实践专家共识
- 《银行业从业人员职业操守和行为准则》课件
评论
0/150
提交评论