<%int id=Integer.parseInt((String)request.getParameter("BookId")); %>
<%String name=(String)request.getParameter("BookName");%>
<%int sale=Integer.parseInt((String)request.getParameter("BookSale"));%>
<%String publish=(String)request.getParameter("BookPublish");%>
<%Class.forName("com.mysql.jdbc.Driver");%>
<%Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bookstore?useSSL=false&serverTimezone=UTC", "root","mysql"); %>
<%String sql="select * from book"; %>
<% PreparedStatement pre=conn.prepareStatement(sql); %>
<% ResultSet rs=pre.executeQuery(); %>
<% if(rs.next()){ %>
<%="查询成功,此书存在" %>
<%} else {%>
<%="查询失败,此书不存在" %>
<%} %>
<% pre.close(); %>
<%conn.close(); %>
<%int id=Integer.parseInt((String)request.getParameter("BookId")); %>
<%String name=(String)request.getParameter("BookName");%>
<%int sale=Integer.parseInt((String)request.getParameter("BookSale"));%>
<%String publish=(String)request.getParameter("BookPublish");%>
<%Class.forName("com.mysql.jdbc.Driver");%>
<%Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bookstore?useSSL=false&serverTimezone=UTC", "root","mysql"); %>
<%String sql="update book set name=?,sale=?,publish=? where id=?"; %>
<% PreparedStatement pre=conn.prepareStatement(sql); %>
<% pre.setString(1, name); %>
<% pre.setInt(2, sale); %>
<% pre.setString(3, publish); %>
<% pre.setInt(4, id); %>
<% int i=pre.executeUpdate(); %>
<% if(i>0) %>
<%="修改成功" %>
<% pre.close(); %>
<%conn.close(); %>
<%int id=Integer.parseInt((String)request.getParameter("BookId")); %>
<%String name=(String)request.getParameter("BookName");%>
<%int sale=Integer.parseInt((String)request.getParameter("BookSale"));%>
<%String publish=(String)request.getParameter("BookPublish");%>
<%Class.forName("com.mysql.jdbc.Driver");%>
<%Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bookstore?useSSL=false&serverTimezone=UTC", "root","mysql");%>
<%String sql="delete from book where id=?"; %>
<% PreparedStatement pre=conn.prepareStatement(sql);%>
<% pre.setInt(1, id); %>
<% int i=pre.executeUpdate(); %>
<% if(i>0){ %>
<%="删除成功" %>
<%} else{%>
<%="删除失败" %>
<%} %>
<% pre.close(); %>
<%conn.close(); %>