succDele.jsp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <%@ page language="java" contentType="text/html; charset=utf-8"%>
  2. <%@ page import="java.sql.*"%>
  3. <% request.setCharacterEncoding("utf-8") ;%>
  4. <%-- <%@ page import="com.mchange.v2.c3p0.ComboPooledDataSource" %> --%>
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8. <meta charset="utf-8">
  9. <title>Insert title here</title>
  10. </head>
  11. <body>
  12. <%
  13. Class.forName("com.mysql.jdbc.Driver");
  14. String url = "jdbc:mysql://localhost:3306/kui"; //指向数据库table1
  15. String username = "root";
  16. String password = "001011";
  17. Connection conn = null;
  18. conn = DriverManager.getConnection(url, username, password);
  19. if(conn != null){
  20. /* Statement stmt = conn.createStatement(); */
  21. String name=request.getParameter("name");
  22. if(name.equals("")){
  23. response.sendRedirect("dele.jsp");
  24. }else{
  25. Statement stmt = null;
  26. ResultSet rs = null;
  27. PreparedStatement pstmt = null;
  28. String sql = "delete from student where name='"+name+"' ";
  29. pstmt = conn.prepareStatement(sql);
  30. pstmt.executeUpdate();
  31. out.print("<style type=\"text/css\">\r\n" +
  32. " @keyframes move{\r\n" +
  33. " 0%{\r\n" +
  34. " color:pink;\r\n" +
  35. " }\r\n" +
  36. " 20%{\r\n" +
  37. " color:skyblue;\r\n" +
  38. " }\r\n" +
  39. " 40%{\r\n" +
  40. " color:red;\r\n" +
  41. " }\r\n" +
  42. " 60%{\r\n" +
  43. " color:blue;\r\n" +
  44. " }\r\n" +
  45. " 80%{\r\n" +
  46. " color:green;\r\n" +
  47. " }\r\n" +
  48. " 90%{\r\n" +
  49. " color:gold;\r\n" +
  50. " }\r\n" +
  51. " }\r\n" +
  52. " h1{\r\n" +
  53. " animation-name: move;\r\n" +
  54. " animation-duration: 10s;\r\n" +
  55. " text-align: center;\r\n" +
  56. " }\r\n" +
  57. " a{\r\n" +
  58. " text-align: center;\r\n" +
  59. " font-size: 28px;\r\n" +
  60. " text-decoration: none;\r\n" +
  61. " }\r\n" +
  62. " .look{\r\n" +
  63. " width: 180px;\r\n" +
  64. " height: 40px;\r\n" +
  65. " border: solid;\r\n" +
  66. " margin: 0 auto;\r\n" +
  67. " text-align: center;\r\n" +
  68. " }\r\n" +
  69. " .look:hover{\r\n" +
  70. " background-color: pink;\r\n" +
  71. " }\r\n" +
  72. " </style>");
  73. out.println("<h1>恭喜!删除成功!</h1><br><br>");
  74. out.println("<div class=\"look\">\r\n" +
  75. " <a href=MMC_01>查看列表</a>\r\n" +
  76. " </div>");
  77. }
  78. }
  79. else{
  80. out.print("连接失败!");
  81. }
  82. %>
  83. <br><br>
  84. <!-- <a href="Student.jsp"> 返回管理首页</a> -->
  85. </body>
  86. </html>