zoukankan      html  css  js  c++  java
  • 每日日报2021.5.24

    今天完成内容:

    学习web

      连接数据库,爬取数据 连接数据库

    package util;

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;

    public class DBUtil {

    private static final String db_url="jdbc:mysql://localhost:3306/e_manager?useUnicode=true&characterEncoding=GB18030&useSSL=false&serverTimezone=GMT&allowPublicKeyRetrieval=true";
    public static String db_user = "root";
    public static String db_pass = "123456";

    public static Connection getConn () {
    Connection conn = null;

    try {
    Class.forName("com.mysql.cj.jdbc.Driver");
    conn = DriverManager.getConnection(db_url, db_user, db_pass);
    } catch (Exception e) {
    e.printStackTrace();
    }

    return conn;
    }

    /**
    * 锟截憋拷锟斤拷锟斤拷
    * @param state
    * @param conn
    */
    public static void close (Statement state, Connection conn) {
    if (state != null) {
    try {
    state.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }

    if (conn != null) {
    try {
    conn.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }
    }

    public static void close (ResultSet rs, Statement state, Connection conn) {
    if (rs != null) {
    try {
    rs.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }

    if (state != null) {
    try {
    state.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }

    if (conn != null) {
    try {
    conn.close();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }
    }
    }

     添加页面

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isELIgnored="false"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <div class="one">
    <div class="two">
    <form action="addServlet" method="post" onsubmit="return check()">
    <table>
    <tr><td>序号</td>
    <td><input type="text" name="id" id="id" /></td>
    </tr>
    <tr>
    <td>名字</td>
    <td><input type="text" name="name" id="name" /></td>
    </tr>
    <tr>
    <td>链接</td>
    <td><input type="text" name="link" id="link"></td>
    </tr>
    <tr>
    <td colspan="2" align="center"><input type="submit" name="submit" value="提交" /></td>
    </tr>
    </table>
    </form>
    </div>
    </div>
    </body>
    </html>

    看视频

    遇到问题:

    明日目标:

    学习web端的开发

    学习css

  • 相关阅读:
    python数据分析——numpy数组学习(2)
    python数据分析——numpy数组学习(2)
    python数据分析——numpy数组学习
    python数据分析——numpy数组及其运算
    python基础学习——列表与列表表达式
    python基础学习——列表与列表表达式
    各国国土面积、军队数量、GDP总计数据分析
    爬取起点月票榜
    《战争艺术概论》词云
    影评网站-团队博客目录
  • 原文地址:https://www.cnblogs.com/leiyu1905/p/14913430.html
Copyright © 2011-2022 走看看