图书管理系统(关于数据库的增删改查)
图书管理系统是我自己想的,东西不太多、主要还是为了练习尝试数据库的增删改查的应用。用到了Javaweb、JavaBean、HTML、servlet、jsp,还望大佬们指点指点。
先看一下项目的整体结构
首先我先创建了数据库和表以及表列名(自己要用到的可以自由加)
关于代码的顺序我仍然是先写了Bean包:get(),set()方法 . //Alt+Shift+S可以快速构建,然后是Util包下的数据库的连接,下面直接上代码
BookInformation.java
package Bean; public class BookInformation { private String number;//编号 private String bookname;//书名 private String writer;//作者 private String quantity;//借阅量 public String getNumber() { return number; } public void setNumber(String number) { this.number = number; } public String getBookname() { return bookname; } public void setBookname(String bookname) { this.bookname = bookname; } public String getWriter() { return writer; } public void setWriter(String writer) { this.writer = writer; } public String getQuantity() { return quantity; } public void setQuantity(String quantity) { this.quantity = quantity; } }
util.java
package Util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; /** * JDBC�������� */ public class util{ public static Connection getConnection() throws ClassNotFoundException, SQLException {//创建了一个方法后面会调用 Connection connection = null;//创建连接对象 PreparedStatement ps = null;////创建载体 ResultSet rs = null;//创建结果集对象 Class.forName("com.mysql.cj.jdbc.Driver"); connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/tushu","root", "jiang123456");//数据库的名称和自己的账号密码记得改!!! return connection; } public static void close(Connection connection ) { try { if (connection != null) { connection.close(); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void close(PreparedStatement preparedStatement ) { try { if (preparedStatement != null) { preparedStatement.close(); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void close(ResultSet resultSet ) { try { if (resultSet != null) { resultSet.close(); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
接着我开始写界面:主界面和增删改都是用到了HTML,查和遍历用到了jsp。下面是各个界面的代码有不同需求的可以适当增删!!!
主界面
zhujiemian.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <h1 align = "center">欢迎使用图书管理系统</h1><br> </head> <body> <div align = "center"> <!-- 居中 --><a href="add.html" > <!-- 链接 --> 登记图书信息</button ></a></div><br> <div align = "center"> <a href="update.html" >修改图书信息</button></a></div><br> <div align = "center"> <a href="delite.html ">删除图书信息</button></a></div><br> <div align = "center"> <a href="select2.html">查询图书信息</button></a></div><br> <div align = "center"> <a href="showall.jsp">浏览图书信息</button></a></div><br> </body> </html>
增加数据界面(下面注释部分是关于增加的方式有需要的可以看之前相关博客)add.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <!-- 添加的方式大概分为文本框(text),按钮(radio、value),下拉框(select、value),多选框()//如果少下了忘大佬们提醒哈 --> <!-- 一、"<input type=text//文本框 name="数据库定义的名字" ||text结束,> <!--二、radio例子如下--> <!-- <tr> <td> 住房类型:</td> <td> <input type="radio" name="zhufangleixing" value="家庭住宅">家庭住所 <input type="radio" name="zhufangleixing" value="集体住所" checked>集体住所 <input type="radio" name="zhufangleixing" value="工作地住所">工作地住所 <input type="radio" name="zhufangleixing" value="其他住宅">其他住宅 <input type="radio" name="zhufangleixing" value="无住宅">无住宅 </td> </tr> radio结束 --> <!-- 三、下拉框 <tr> <td>受教育程度:</td> <td> <select name="jiaoyuchengdu"> <option value="研究生">研究生</option> <option value="大学本科">大学本科</option> <option value="大学专科">大学专科</option> <option value="高中" selected>高中</option> <option value="初中">初中</option> <option value="小学">小学</option> <option value="未上过学">未上过学</option> </select> </td> </tr> --> <!-- 四、多选框 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <form action="demo04.jsp" > 用户名:<input type="text" name="uname"><br> 兴趣: <input type="checkbox" name="inst" value="bask">篮球 <input type="checkbox" name="inst" value="swim">游泳 <input type="checkbox" name="inst" value="sing">唱歌 <input type="checkbox" name="inst" value="dancd">跳舞 <input type="checkbox" name="inst" value="read">看书 <br> <input type="submit" value="提交"> </form> </body> </html> --> <body> <div id="addSubjectForm" align="center"> <form action="add1" method="post"><!-- servlet里要调用的函数 --> <tr> <h2>请输入图书信息</h2> </tr> <table align="center"> <tr> <td>图书编号:</td> <td> <input type="text" name="number" > </td> </tr> <tr> <td>书名:</td> <td> <input type="text" name="bookname" > </td> </tr> <tr> <td>图书作者:</td> <td> <input type="text" name="writer" > </td> </tr> <tr> <td>借阅可借阅数量:</td> <td> <input type="text" name="quantity" > </td> </tr> <td> <input type="submit" value="提交" /> <input type="reset" value="重置" /> <input type="button" name="Submit" onclick="javascript:history.back(-1);" value="返回上一页"> </td> </body> </html>
删除数据界面(我这一块是根据图书的编号来删除的有其他要求的可以适当的增删)delite.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <div id="addSubjectForm" align="center"> <form action="delite1" method="post"><!-- servlet里要调用的函数 --> <tr> <h2>请输入要删除的图书信息</h2> </tr> <table align="center"> <tr> <td>图书编号:</td> <td> <input type="text" name="number" > </td> </tr> <td> <input type="submit" value="提交" /> <input type="reset" value="重置" /> <input type="button" name="Submit" onclick="javascript:history.back(-1);" value="返回上一页"> </td> </body> </html>
修改数据界面(修改数据则是以图书书名为主作为修改,有其余要求可以适当增删)update.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <div id="addSubjectForm" align="center"> <form action="uapata1" method="post"><!-- servlet里要调用的函数 --> <tr> <h2>请输入要修改的图书书名</h2> </tr> <table align="center"> <tr> <td>图书编号:</td> <td> <input type="text" name="number" > </td> </tr> <tr> <td>书名:</td> <td> <input type="text" name="bookname" > </td> </tr> <tr> <td>图书作者:</td> <td> <input type="text" name="writer" > </td> </tr> <tr> <td>图书可借阅得数量:</td> <td> <input type="text" name="quantity" > </td> </tr> <td> <input type="submit" value="提交" /> <input type="reset" value="重置" /> <input type="button" name="Submit" onclick="javascript:history.back(-1);" value="返回上一页"> </td> </body> </html>
后面两个我会给出查询和遍历的主界面我用到了jsp。
遍历数据界面:用到了ArrayList集合接受后端数据(servlet包下),遍历showall.jsp
<%@page import="Dao.showall"%> <%@page import="java.util.ArrayList"%> <%@page import="Bean.BookInformation"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>展示数据</title> </head> <body> <table border="1"> <tr> <th>图书编号</th> <th>书名</th> <th>图书作者</th> <th>借阅时间</th> <div>return Home ? <a href="zhujiemian.html">home</a></div> </tr> <% ArrayList <BookInformation> people = new ArrayList<BookInformation>(); showall dao = new showall(); dao.showall(people); for (int i = 0; i < people.size(); i++) { BookInformation A = people.get(i); %> <tr> <td><%=A.getNumber()%></td> <td><%=A.getBookname()%></td> <td><%=A.getWriter()%></td> <td><%=A.getQuantity()%></td> </tr> <% } %> </table> </body> </html>
查询数据界面“select2”:查询则是按照书的名称查询有其他需求的可以创多个界面进行不同查询select2.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <!-- "<input type=radio//按钮text//文本框 name="数据库定义的名字" ||text结束,radio例子如下> <!-- <tr> <td> 住房类型:</td> <td> <input type="radio" name="zhufangleixing" value="家庭住宅">家庭住所 <input type="radio" name="zhufangleixing" value="集体住所" checked>集体住所 <input type="radio" name="zhufangleixing" value="工作地住所">工作地住所 <input type="radio" name="zhufangleixing" value="其他住宅">其他住宅 <input type="radio" name="zhufangleixing" value="无住宅">无住宅 </td> </tr> --> <!-- 下拉框 <tr> <td>受教育程度:</td> <td> <select name="jiaoyuchengdu"> <option value="研究生">研究生</option> <option value="大学本科">大学本科</option> <option value="大学专科">大学专科</option> <option value="高中" selected>高中</option> <option value="初中">初中</option> <option value="小学">小学</option> <option value="未上过学">未上过学</option> </select> </td> </tr> --> <body> <div id="addSubjectForm" align="center"> <form action="select9" method="post"><!-- servlet里要调用的函数 --> <tr> <h2>请输入要查询的图书信息</h2> </tr> <table align="center"> <tr> <td>图书作者:</td> <td> <input type="text" name="bookname" > </td> </tr> <td> <input type="submit" value="提交" /> <input type="reset" value="重置" /> <input type="button" name="Submit" onclick="javascript:history.back(-1);" value="返回上一页"> </td> </body> </html>
查询还有一个jsp文件我是在界面进行遍历输出也可以直接在servlet包下进行遍历输出。
select.jsp
<%@page import="Util.util"%> <%@page import="Servlet.select9"%> <%@page import="java.util.ArrayList"%> <%@page import="java.util.List"%> <%@page import="Bean.BookInformation"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>展示数据</title> </head> <body> <table border="1"> <tr> <th>图书编号</th> <th>图书名称</th> <th>作者</th> <th>可借阅数量</th> </tr> <% //先把数据取出来,通过request对象(内置对象,不需要我们去创建,其实是httpservletRequest对象的实例) ArrayList <BookInformation> book = (ArrayList<BookInformation> )request.getAttribute("book"); for (int i = 0; i < book.size(); i++) { BookInformation book1 = book.get(i);//user是个变量 %> <tr> <td><%=book1.getNumber()%></td> <td><%=book1.getBookname()%></td> <td><%=book1.getWriter()%></td> <td><%=book1.getQuantity()%></td> </tr> <% } %> </table> </body> </html>
写到这里所有的界面基本上都已经完成然后就着手于后端。Dao包和servlet包。
Dao包下写的是工具类基本上就是SQL语句,是class文件,servlet下则是写的与数据库前端的交互,用到的是servlet文件这里还需要导一个jar包
”servlet-api.jar“ 包可以在你下载的tomcat,lib目录下里找到.(上面少一个jsp文件“select.jsp”记得加上)
接下来我会给出Dao包和servlet包下的代码
add.java
package Dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import Bean.BookInformation; import Util.util; public class add { //创建连接对象,载体,结果集对象 // private static Connection conn=null; // private static PreparedStatement ps=null; // private static ResultSet rs=null; public void add(BookInformation A) throws ClassNotFoundException, SQLException { Connection connection = util.getConnection(); String sql = "INSERT INTO test (number,bookname,writer,quantity) values(?,?,?,?)"; PreparedStatement preparedStatement = null;//载体 try { // preparedStatement = connection.prepareStatement(sql); // preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, A.getNumber()); preparedStatement.setString(2, A.getBookname()); preparedStatement.setString(3, A.getWriter()); preparedStatement.setString(4, A.getQuantity()); System.out.println(A.getNumber());//测试用 preparedStatement.executeUpdate(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally { } } }
delite.java
package Dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import Bean.BookInformation; import Util.util; public class delite { public void delite(BookInformation A) throws ClassNotFoundException, SQLException { Connection connection = util.getConnection(); String sql = "delete from test where number=?"; PreparedStatement preparedStatement = null; // preparedStatement = connection.prepareStatement(sql); // preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, A.getNumber());//获取编号 System.out.println(A.getNumber());//测试用 preparedStatement.executeUpdate(); } }
select.java
package Dao; import java.io.PrintWriter; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import Bean.BookInformation; import Util.util; import Bean.BookInformation; import Util.util; public class select { //创建连接对象,载体,结果集对象 // private static Connection conn=null; // private static PreparedStatement ps=null; // private static ResultSet rs=null; public void select11(ArrayList<BookInformation> book,String name) throws ClassNotFoundException, SQLException{ String sql1 ="select * from test where bookname = ?"; Connection connection = util.getConnection(); try { PreparedStatement ps = connection.prepareStatement(sql1); ps.setString(1, name); ResultSet rs = ps.executeQuery(); while(rs.next()) { BookInformation A = new BookInformation(); A.setNumber(rs.getString(1)); A.setBookname(rs.getString(2)); A.setWriter(rs.getString(3)); A.setQuantity(rs.getString(4)); book.add(A); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
showall.java
package Dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import Bean.BookInformation; import Util.util; public class showall { public void showall(ArrayList<BookInformation> people) throws ClassNotFoundException, SQLException{ String sql1 ="select * from test"; //������䴫����� Connection connection = util.getConnection(); try { PreparedStatement ps = connection.prepareStatement(sql1); ResultSet rs = ps.executeQuery(); while(rs.next()) { BookInformation A = new BookInformation(); A.setNumber(rs.getString(1)); A.setBookname(rs.getString(2)); A.setWriter(rs.getString(3)); A.setQuantity(rs.getString(4)); people.add(A); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
updata.java
package Dao; import java.io.PrintWriter; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import Bean.BookInformation; import Util.util; public class updata { //创建连接对象,载体,结果集对象 // private static Connection conn=null; // private static PreparedStatement ps=null; // private static ResultSet rs=null; public void updata(BookInformation A) throws ClassNotFoundException, SQLException { Connection connection = util.getConnection(); String sql = " update test set number = ?,bookname = ?,writer = ?,quantity = ?"; PreparedStatement preparedStatement = null;//载体 try { preparedStatement = connection.prepareStatement(sql); // preparedStatement = connection.prepareStatement(sql); preparedStatement.setString(1, A.getNumber()); preparedStatement.setString(2, A.getBookname()); preparedStatement.setString(3, A.getWriter()); preparedStatement.setString(4, A.getQuantity()); System.out.println(A.getNumber());//测试用 preparedStatement.executeUpdate(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally { } } }
上面这些是Dao包下的(也就是工具类放SQL方法的)
下面是SERVLET包下(创建的是servlet文件不是class文件里注意!!!)
add1.java
package Servlet; import java.io.IOException; import java.sql.SQLException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import Bean.BookInformation; import Dao.add; /** * Servlet implementation class add */ public class add1 extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public add1() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doPost(request,response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub // TODO Auto-generated method stub request.setCharacterEncoding("utf-8"); //������Ӧ���ı����� response.setContentType("text/html;charset=utf-8");//设置字符集 String number = request.getParameter("number"); String bookname = request.getParameter("bookname"); String writer = request.getParameter("writer"); String quantity = request.getParameter("quantity"); // System.out.println(number); BookInformation B = new BookInformation(); B.setNumber(number); B.setBookname(bookname); B.setWriter(writer); B.setQuantity(quantity); // response.sendRedirect("showall.jsp");\ add A=new add(); try { A.add(B); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}
delite1.java
package Servlet; import java.io.IOException; import java.sql.SQLException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import Bean.BookInformation; import Dao.delite; /** * Servlet implementation class delite1 */ @WebServlet("/delite1") public class delite1 extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public delite1() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doPost(request,response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub // TODO Auto-generated method stub request.setCharacterEncoding("utf-8"); //������Ӧ���ı����� response.setContentType("text/html;charset=utf-8");//设置字符集 String number = request.getParameter("number"); BookInformation B = new BookInformation(); B.setNumber(number); // response.sendRedirect("showall.jsp");\ delite A=new delite(); try { A.delite(B); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}
select9.java
package Servlet; import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import Bean.BookInformation; import Dao.select; import Bean.BookInformation; import Dao.select; import Util.util; /** * Servlet implementation class add */ public class select9 extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public select9() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doPost(request,response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub // TODO Auto-generated method stub request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); String bookname = request.getParameter("bookname");; ArrayList <BookInformation> book = new ArrayList<BookInformation>(); //���ݿ���� System.out.println(bookname); select dao=new select(); if(bookname!=null) { try { dao.select11(book,bookname); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } request.setAttribute("book",book);//setAttribute() 方法添加指定的属性,并为其赋指定的值。 request.getRequestDispatcher("select.jsp").forward(request, response); } else { response.getWriter().write("输入数据不存在请重新输入。"); } // else if(number!=null) { // try { // dao.select1(book,number); // } catch (ClassNotFoundException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } catch (SQLException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // request.setAttribute("people",people); // request.getRequestDispatcher("chakan.jsp").forward(request, response); // } // else if(minzu!=null) { // try { // dao.select4(people,minzu); // } catch (ClassNotFoundException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } catch (SQLException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // request.setAttribute("people",people); // request.getRequestDispatcher("chakan.jsp").forward(request, response); // } // else { // try { // dao.select5(people,jiaoyuchengdu); // } catch (ClassNotFoundException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } catch (SQLException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // request.setAttribute("people",people); // request.getRequestDispatcher("chakan.jsp").forward(request, response); // } }}
updata.java
package Servlet; import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import Bean.BookInformation; import Dao.updata; import Util.util; /** * Servlet implementation class add */ public class uapata1 extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public uapata1() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doPost(request,response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub // TODO Auto-generated method stub request.setCharacterEncoding("utf-8"); //������Ӧ���ı����� response.setContentType("text/html;charset=utf-8");//设置字符集 String number = request.getParameter("number"); String bookname = request.getParameter("bookname"); String writer = request.getParameter("writer"); String quantity = request.getParameter("quantity"); // System.out.println(number); // String Bookname[]=new String [100]; String Number[]=new String[100]; int i=0,j=0,count=0; try{Connection connection = util.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("select * from test");//载体 ResultSet set=preparedStatement.executeQuery("select * from test"); while(set.next()) { Bookname[i]=set.getString("bookname"); Number[i]=set.getString("number"); i++; count++; } for(int k=0;k<count;k++) { if(bookname.equals(Bookname[k])) { BookInformation B = new BookInformation(); B.setNumber(number); B.setBookname(bookname); B.setWriter(writer); B.setQuantity(quantity); // response.sendRedirect("showall.jsp");\ updata A=new updata(); try { A.updata(B); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } break; } else{ response.sendRedirect("print.html"); } }} catch(SQLException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}
到这里基本就结束了还有些功能还未完善后期会再次更新。