12.12

发布时间 2023-12-18 22:13:03作者: 张佳木

今日学习内容

<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.*" %><%--
Created by IntelliJ IDEA.
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>
<%
String name=request.getParameter("name");
String destination=request.getParameter("destination");
String departuredate=request.getParameter("departuredate");
String returndate=request.getParameter("returndate");
String Type=request.getParameter("Type");
String Typecontent=request.getParameter("Typecontent");
String Reason=request.getParameter("Reason");

try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
request.setCharacterEncoding("utf-8");
Connection conn = null;
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/2023shenpi", "root", "123456");
Statement stat = null;
stat = conn.createStatement();
String sql = "UPDATE chuchai set destination = ('"+destination+"'),departuredate=('"+departuredate+"'),returndate=('"+returndate+"'),Reason=('"+Reason+"'),Typecontent=('"+Typecontent+"'),Type=('"+Type+"') where name= ('"+name+"') " ;
stat.executeUpdate(sql);
out.println("修改成功");
stat.close();
conn.close();
%>

</body>
</html>