JavaEE of Mybatis encountered pit 1
After writing the relevant logic code, the following error appears
Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"user" (username,password,phone,email) VALUES('TWG','123','15107793356','[email protected]' at line 1
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"user" (username,password,phone,email) VALUES('TWG','123','15107793356','[email protected]' at line 1
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
So I checked the following SQL statements in the XML several times and found that there is no problem
<mapper namespace="com.twgfs.ui.dao.LoginRegistServiceDao">
<insert id="Registing">
INSERT INTO "user" (username,password,phone,email) VALUES(#{username},#{password},#{phone},#{email})
</insert>
</mapper>
So I had to try one by one, and finally I realized that at the time of writing INSERTINTO automatically prompts the user table name and then I easily press the Enter so he wrote the quoted "user" table name so it has been suggested error!