• 2021.5.13


    三--2

    <%@ page contentType="text/html; charset=utf-8" import="java.sql.*" errorPage="error.jsp"%>
    <html>
    <head>
    <title>添加信息</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
    </head>
    <body>
    <%
    request.setCharacterEncoding("utf-8");
    String stunum = request.getParameter("stunum");
    String stuname = request.getParameter("stuname");
    String sex = request.getParameter("sex");
    String birthday = request.getParameter("birthday");
    String location = request.getParameter("location");
    Class.forName("com.mysql.cj.jdbc.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/student?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false", "root", "123456");


    PreparedStatement stmt = con.prepareStatement("insert into studentinfo(num,name,sex,birthday,location) values(?, ?, ? ,? ,?)");
    stmt.setInt(1, Integer.valueOf(stunum));
    stmt.setString(2, stuname);
    stmt.setString(3, sex);
    stmt.setString(4, birthday);
    stmt.setString(5, location);
    int i = stmt.executeUpdate();


    if (i == 1) {
    out.println("<h2>添加成功!</h2><br/>");
    out.println("<a href='index.jsp'>返回首页</a>");
    } else {
    out.println("<h2>添加失败!</h2><br/>");
    out.println("<a href='add.jsp'>重新添加</a>");
    }
    stmt.close();
    con.close();

    %>
    </body>
    </html>

  • 相关阅读:
    POJ 2388(排序)
    优先队列(堆实现)
    POJ 3322(广搜)
    POJ 1190(深搜)
    POJ 1456(贪心)
    poj 2524 (并查集)
    poj 1611(并查集)
    poj 1521
    poj 1220(短除法)
    css 如何实现图片等比例缩放
  • 原文地址:https://www.cnblogs.com/SirNie/p/14909275.html
Copyright © 2020-2023  润新知