2024/4/17
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.sql.PreparedStatement" %><%--
Created by IntelliJ IDEA.
User: 联想
Date: 2023/11/20
Time: 16:38
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String url = "jdbc:mysql://localhost:3306/fish?serverTimezone=UTC&useSSL=false&characterEncoding=UTF-8";
String username = "root";
String password = "123456";
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(url, username, password);
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
String name = request.getParameter("name");
try {
String sql = "DELETE FROM message1 WHERE name = ?";
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setString(1, name);
stmt.executeUpdate();
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}request.getRequestDispatcher("success.jsp").forward(request, response);
%>
</body>
</html>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.sql.PreparedStatement" %><%--
Created by IntelliJ IDEA.
User: 联想
Date: 2023/11/20
Time: 16:38
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String url = "jdbc:mysql://localhost:3306/fish?serverTimezone=UTC&useSSL=false&characterEncoding=UTF-8";
String username = "root";
String password = "123456";
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(url, username, password);
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
String name = request.getParameter("name");
try {
String sql = "DELETE FROM message1 WHERE name = ?";
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setString(1, name);
stmt.executeUpdate();
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}request.getRequestDispatcher("success.jsp").forward(request, response);
%>
</body>
</html>