Tag Archives: ProgrammerAH

About starting the service, you always get stuck in com. Alibaba. Druid. Pool. Druiddatasource | {datasource-1} initiated

Today, when debugging the program, it was good. Later, when restarting the service, it was stuck behind the log of com.alibaba.druid.pool.druiddatasource | {datasource-1} initiated, as shown in the figure

After a variety of debugging, restart or card here

Finally, I found that I made a breakpoint in a method of mapper interface, which is a real fucker

After canceling the breakpoint, it starts successfully  

{“errcode“:40125,“errmsg“:“invalid appsecret, view more at http:\/\/t.cn\/RAEkdVq rid: 60d999f2-3ad5

1 question

{“errcode”:40125,“errmsg”:“invalid appsecret, view more at http://t.cn/RAEkdVq rid: 60d999f2-3ad58b98-4b237e0d”}

2 reasons

    the wechat appsecret set in the code is inconsistent with the wechat open platform. You need to check and correct it by comparing the wechat open platform with the appsecret in the code. Because the secret key is invalid, if the secret key does not log in for a long time, it will be reset automatically

    3 solutions

    Reset the secret key and replace it with the reset one

    4 Communication

    If you have other communication ideas, you can add the technology group I created: 820080257

The local network card cannot be obtained by opening Wireshark

After installing and opening wireahrk, the local network card cannot be found and the packet cannot be captured

terms of settlement:

1. Run Wireshark as an administrator

2. Method 1 cannot solve the problem. Try to run the command →

Type: Net start NPF  

3. Method 2 cannot solve the problem. Try to download WinPcap and run Wireshark directly after installation

Elasticsearch starts error summary

error1:   The default startup user of elasticsearch is the non root user, and you can switch to the non root user.

erorr2:   The elasticsearch installation package belongs to the root group, and you can modify the permission group to a non root group.

Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

The following error occurred in Maven install because the testsendattachmentsmail method did not pass the test

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.032 sec

Results :

Tests in error: 
  testSendAttachmentsMail(com.weichen.house.biz.service.impl.MailSeviceImplTest): Failed messages: javax.mail.MessagingException: IOException while sending message;(..)

Tests run: 6, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] house-parent 1.0.0-SNAPSHOT ........................ SUCCESS [  0.446 s]
[INFO] house-common ....................................... SUCCESS [  3.833 s]
[INFO] house-biz .......................................... SUCCESS [  1.927 s]
[INFO] house-web 1.0.0-SNAPSHOT ........................... FAILURE [ 24.759 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 31.540 s
[INFO] Finished at: 2021-06-28T21:10:04+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project house-web: There are test failures.
[ERROR] 
[ERROR] Please refer to H:\Fangdichang\MyprojectWorkSpace\house\house-web\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project house-web: There are test failures.

Please refer to H:\Fangdichang\MyprojectWorkSpace\house\house-web\target\surefire-reports for the individual test results.
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.

Please refer to H:\Fangdichang\MyprojectWorkSpace\house\house-web\target\surefire-reports for the individual test results.
	at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:83)
	at org.apache.maven.plugin.surefire.SurefirePlugin.writeSummary(SurefirePlugin.java:176)
	at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:150)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:650)
	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:586)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
	... 20 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :house-web

@Controlleradvice exception [How to Solve]

ControllerAdvice

 @ControllerAdviceSpring 3.2 provides a new annotation, which is a Controller enhancer that adds some logic to the methods annotated by @RequestMapping in the controller. The most common one is exception handling

2: @controlleradvice with exception handler

When throwing exceptions to the controller, you can unify the exception handling by specifying the returned json format or jumping to an error page

3: Examples

@Slf4j
 @ControllerAdvice
 public class ExceptionHandlerAdvice {

     @ResponseStatus(HttpStatus.OK)
     @ResponseBody
     @ExceptionHandler({MethodArgumentNotValidException.class})
     public <T> ResponseEntity<ResultDTO<T>> handleBusinessException(MethodArgumentNotValidException method) {
         String defaultMessage = method.getBindingResult().getFieldError().getDefaultMessage();
         log.error("Error in parameters: {}", defaultMessage);
         return ResponseEntity.ok(ResultDTO.getErrorResult(defaultMessage));
     }

     @ResponseStatus(HttpStatus.OK)
     @ResponseBody
     @ExceptionHandler(ValidationException.class)
     public <T> ResponseEntity<ResultDTO<T>> handleBusinessException(ValidationException exception) {
         String defaultMessage = exception.getMessage();
         log.error("Error in parameters,{}", defaultMessage);
         return ResponseEntity.ok(ResultDTO.getErrorResult(defaultMessage));
     }
 }

Serverlet: How to Add, Delete, Modify and Query item code

Serverlet project code

Define database connection closure

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.*;

public class DBManager {
	
	private static final String DRIVERNAME = "com.mysql.jdbc.Driver";
	private static final String URL = "jdbc:mysql://127.0.0.1:3306/bbs?useUnicode=true&characterEncoding=utf8";
	private static final String USERNAME = "root";
	private static final String USERPWD = "123456";
	
	public Connection getconn() throws ClassNotFoundException, SQLException {
		Class.forName(DRIVERNAME);
		Connection conn=DriverManager.getConnection(URL,USERNAME,USERPWD);
		System.out.print("DB Success!!");
		return  conn;
		
	}
	
	public void closeAll(ResultSet rs,PreparedStatement pstmt,Connection conn) throws SQLException {
			if(rs!=null) {
				rs.close();
			}
			if(pstmt!=null) {
				pstmt.close();
			}
			if(conn!=null) {
				conn.close();
			}
	}	
}

Add, delete, change and search (BaseDao)

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * 
 * @author Administrator
 *General method of adding, deleting and checking
 */
public class BaseDao {

	public boolean insert_update_del(String sql,Object val[]) throws ClassNotFoundException, SQLException {
		boolean flag=false;
		Connection con=new DBManager().getconn();
		PreparedStatement pstmt=con.prepareStatement(sql);
		if(val!=null) {
			for(int i=0;i<val.length;i++) {
				pstmt.setObject(i+1, val[i]);
			}			
		}	
		if(pstmt.executeUpdate()>0) {
			flag=true;
		}
		return flag;
	}
	
	public ResultSet query(String sql,Object val[]) throws ClassNotFoundException, SQLException {
		boolean flag=false;
		Connection con=new DBManager().getconn();
		PreparedStatement pstmt=con.prepareStatement(sql);
		if(val!=null) {
			for(int i=0;i<val.length;i++) {
				pstmt.setObject(i+1, val[i]);
			}			
		}	
		ResultSet rs=pstmt.executeQuery();
		return rs;
	}
}

Inherit, add, delete, modify and query

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class StudentsDao extends BaseDao{
	
	public boolean regeditStudent(Student stu) throws ClassNotFoundException, SQLException {
		String sql="insert into students values (null,?,?)";
		Object[] val= {stu.getSname(),stu.getSpwd()};
		return insert_update_del(sql,val);
	}
	
	public List<Student> quaryAll() throws ClassNotFoundException, SQLException{
		List<Student> list=new ArrayList<Student>();
		String sql="select * from students";
		Object[] val= {};
		ResultSet rs=query(sql,val);
		while(rs.next()) {
			Student stu=new  Student();
			stu.setSid(rs.getInt("sid"));
			stu.setSname(rs.getString("sname"));
			stu.setSpwd(rs.getString("spwd"));
			list.add(stu);
		}
		return list;
	}
	public Student queryById(int sid) throws ClassNotFoundException, SQLException {
		Student stu=new Student();
		String sql="select * from students where sid=?";
		Object[] val= {sid};
		ResultSet rs=query(sql,val);
		while(rs.next()) {
			stu.setSid(rs.getInt("sid"));
			stu.setSname(rs.getString("sname"));
			stu.setSpwd(rs.getString("spwd"));
		}
		return stu;
	}
	public boolean updateStudent(Student stu) throws ClassNotFoundException, SQLException {
//		Student stu=new Student();
		String sql="update students set sname=?,spwd=?where sid=?";
		Object[] val= {stu.getSname(),stu.getSpwd(),stu.getSid()};
		if(insert_update_del(sql,val)) {
			return true;
		}
		else {
			return false;
		}
	}
}

RegeditServlet

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class RegeditServlet
 */
@WebServlet("/RegeditServlet")
public class RegeditServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegeditServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
//		doGet(request, response);
		System.out.println("Welcome……");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		
		String sname=request.getParameter("uname");
		String spwd=request.getParameter("upwd");
		Student stu=new Student();
		stu.setSname(sname);
		stu.setSpwd(spwd);
		try {
			if(new StudentsDao().regeditStudent(stu)) {
//				response.sendRedirect("success.jsp");
				response.sendRedirect("queryAllServlet");
			}else {
				response.sendRedirect("error.jsp");
			}
		} catch (ClassNotFoundException | SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}

Registration page (regedit)

<%@ page language="java" contentType="text/html; charset=utf-8"
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<h1>User registration page</h1>
	<form action="regeditservlet" method="post">
		<p>ursename:<input type="text" name="uname"/></p>
		<p>password:<input type="password" name="upwd"/></p>
		<input type="submit" value="register"/>
		
	</form>

</body>
</html>

Error page

<%@ page language="java" contentType="text/html; charset=utf-8"
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<h1>Failed to register</h1>
</body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/Demo4.xsd" id="WebApp_ID" version="3.1">
  <display-name>Demo4</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>regeditservlet</servlet-name>
    <servlet-class>aaa.com.RegeditServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>regeditservlet</servlet-name>
    <url-pattern>/regeditservlet</url-pattern>
  </servlet-mapping>
  
  <!--Add additional content here -->

</web-app>

EditServlet

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class EditServlet
 */
@WebServlet("/EditServlet")
public class EditServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EditServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
//		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
//		doGet(request, response);
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		
		try {
			int sid=Integer.parseInt(request.getParameter("uid"));
			String sname=request.getParameter("uname");
			System.out.println(sname);
			String spwd=request.getParameter("upwd");
			System.out.println(spwd);
			Student stu=new Student();
			stu.setSid(sid);
			stu.setSname(sname);
			stu.setSpwd(spwd);
		
			if(new StudentsDao().updateStudent(stu)) {
				response.sendRedirect("queryallservlet");
			}else {
				response.sendRedirect("error.jsp");
			}
		} catch (ClassNotFoundException | SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}

QueryAllServlet

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class QueryAllServlet
 */
@WebServlet("/queryAllServlet")
public class QueryAllServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public QueryAllServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		try {
			List<Student> list=new StudentsDao().quaryAll();
			request.setAttribute("list", list);
			request.getRequestDispatcher("show.jsp").forward(request, response);
		} catch (ClassNotFoundException | SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}

Show page

<%@ page language="java" contentType="text/html; charset=utf-8"
    %>
<%@ page import="java.util.*" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<h1>User Information Details</h1>
<table>
<tr>
	<td>num</td>
	<td>name</td>
	<td>password</td>
	<td>Operation</td>
<tr>

<c:forEach var="stu" items="${list}" step="1">
<tr>
	<td>${stu.sid}</td>
	<td>${stu.sname}</td>
	<td>${stu.spwd}</td>
	<td><a href="updateservlet?sid=${stu.sid}">修改</a>|<a href="delserverlet?sid=${stu.sid}">删除</a></td>
<tr>
</c:forEach>


</table>
</body>
</html>

web.xml

  <servlet>
    <servlet-name>editservlet</servlet-name>
    <servlet-class>aaa.com.EditServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>editservlet</servlet-name>
    <url-pattern>/editservlet</url-pattern>
  </servlet-mapping>

web.xml

  <servlet>
    <servlet-name>queryallservlet</servlet-name>
    <servlet-class>aaa.com.QueryAllServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>queryallservlet</servlet-name>
    <url-pattern>/queryallservlet</url-pattern>
  </servlet-mapping>

UpdateServlet

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class UpdateServlet
 */
@WebServlet("/updateServlet")
public class UpdateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public UpdateServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
//		response.getWriter().append("Served at: ").append(request.getContextPath());
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		int sid=Integer.parseInt(request.getParameter("sid"));
		System.out.println(sid);
		Student stu=new Student();
		try {
			stu=new StudentsDao().queryById(sid);
			request.setAttribute("stu", stu);
			request.getRequestDispatcher("update.jsp").forward(request, response);
//			System.out.println(stu.sid);
		} catch (ClassNotFoundException | SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}

Modify page

<%@ page language="java" contentType="text/html; charset=utf-8"
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>
<h1>user update</h1>
	<form action="editservlet" method="post">
		<p>number:<input type="text" name="uid" readonly="readonly" value="${stu.sid}"/></p>
		<p>username:<input type="text" name="uname" value="${stu.sname}"/></p>
		<p>password:<input type="password" name="upwd" value="${stu.spwd}"/></p>
		<input type="submit" value="modify"/>
		
	</form>
</body>
</html>

web.xml

  <servlet>
    <servlet-name>updateservlet</servlet-name>
    <servlet-class>aaa.com.UpdateServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>updateservlet</servlet-name>
    <url-pattern>/updateservlet</url-pattern>
  </servlet-mapping>

SubServer

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class DeleteServlet
 */
@WebServlet("/DeleteServlet")
public class DeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DeleteServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
//		response.getWriter().append("Served at: ").append(request.getContextPath());
		doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		int sid = Integer.parseInt(request.getParameter("sid"));
		Student stu=new Student();
		stu.setSid(sid);
		try {
			if(new StudentsDao().deleteStudent(sid)) {
				response.sendRedirect("queryAllServlet");
			}else {
				response.sendRedirect("error.jsp");
			}
		} catch (ClassNotFoundException | SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}

web.xml

  <servlet>
    <servlet-name> delserverlet</servlet-name>
    <servlet-class>aaa.com.DelServerlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>delserverlet</servlet-name>
    <url-pattern>/delserverlet</url-pattern>
  </servlet-mapping>

Gateway Error: Cannot resolve org.springframework.cloud:spring-cloud-starter-gateway:unknown

Reason: there is no version with the same version as springboot, so you need to add your own version model
eg:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>dtestgateway</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>dtestgateway</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
<!--        <dependency>-->
<!--            <groupId>org.springframework.boot</groupId>-->
<!--            <artifactId>spring-boot-starter-web</artifactId>-->
<!--        </dependency>-->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
            <version>3.0.1</version>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>


    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

host ‘‘ is not allowed to connect to this mysql server Connect MYSQL Error

1. When you plan to open your database with MySQL – H (IP address of host) – U (user name) – P, the error host ‘is not allowed to connect to this MySQL server is reported
reason: remote login is not allowed in MySQL Step 1: MySQL – U (user name) – P
Step 2: enter use MySQL
Step 3: enter update user set host = ‘%’ where user =’root ‘

4. After connecting, test example:

import pymysql

#Establish a connection
conn = pymysql. Connect (
0   Host =
your IP address   user=”root”,  # User name
Passwd = “root”, # user password
0   DB = (test) # database name

#To create a cursor, the default is meta group type
cursor = conn.cursor()
sql = “select * from student” # the name of the table in the database

cursor.execute(sql)
res = cursor.fetchall()
print(res)

cursor.close()
conn.close()