测试reset_password.do是出现500错误如何解决

来源:6-9 用户模块所有功能自测试

Ray慕

2021-04-26

HTTP Status 500 – Internal Server Error


Type Exception Report

Message Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException:

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  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 'now() 
    where id = 1' at line 26
### The error may involve com.mmall.dao.UserMapper.updateByPrimaryKeySelective-Inline
### The error occurred while setting parameters
### SQL: update mmall_user      SET username = ?,                       password = ?,                       email = ?,                       phone = ?,                       question = ?,                       answer = ?,                       role = ?,                       create_time = ?,                       now()      where id = ?
### 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 'now() 
    where id = 1' at line 26
; 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 'now() 
    where id = 1' at line 26
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:943)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:833)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
	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:88)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)

Root Cause

org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  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 'now() 
    where id = 1' at line 26
### The error may involve com.mmall.dao.UserMapper.updateByPrimaryKeySelective-Inline
### The error occurred while setting parameters
### SQL: update mmall_user      SET username = ?,                       password = ?,                       email = ?,                       phone = ?,                       question = ?,                       answer = ?,                       role = ?,                       create_time = ?,                       now()      where id = ?
### 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 'now() 
    where id = 1' at line 26
; 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 'now() 
    where id = 1' at line 26
	org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
	org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
	org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
	org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447)
	com.sun.proxy.$Proxy21.update(Unknown Source)
	org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:295)
	org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
	org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
	com.sun.proxy.$Proxy22.updateByPrimaryKeySelective(Unknown Source)
	com.mmall.service.impl.UserServiceImpl.resetPassword(UserServiceImpl.java:147)
	com.mmall.controller.portal.UserController.resetPassword(UserController.java:95)
	jdk.internal.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:564)
	org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214)
	org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
	org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:748)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
	org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:833)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
	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:88)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)

Root 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 'now() 
    where id = 1' at line 26
	jdk.internal.reflect.GeneratedConstructorAccessor155.newInstance(Unknown Source)
	java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
	com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
	com.mysql.jdbc.Util.getInstance(Util.java:381)
	com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
	com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
	com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
	com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
	com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
	com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
	com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
	com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
	com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:995)
	org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
	org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
	jdk.internal.reflect.GeneratedMethodAccessor50.invoke(Unknown Source)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:564)
	org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
	com.sun.proxy.$Proxy26.execute(Unknown Source)
	org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)
	org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
	org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
	org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
	org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
	jdk.internal.reflect.GeneratedMethodAccessor76.invoke(Unknown Source)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:564)
	org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
	com.sun.proxy.$Proxy24.update(Unknown Source)
	org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
	jdk.internal.reflect.GeneratedMethodAccessor79.invoke(Unknown Source)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:564)
	org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434)
	com.sun.proxy.$Proxy21.update(Unknown Source)
	org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:295)
	org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
	org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
	com.sun.proxy.$Proxy22.updateByPrimaryKeySelective(Unknown Source)
	com.mmall.service.impl.UserServiceImpl.resetPassword(UserServiceImpl.java:147)
	com.mmall.controller.portal.UserController.resetPassword(UserController.java:95)
	jdk.internal.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:564)
	org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:214)
	org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
	org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:748)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
	org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:931)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:833)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:807)
	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:88)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)

Note The full stack trace of the root cause is available in the server logs.


Apache Tomcat/8.5.31


写回答

1回答

geelylucky

2021-05-05

500状态码一般是后端有异常产生 导致吃错误

从贴出的异常看是个mybatis 的sql 拼写异常

建议debug或者将sql打印到控制台 检查下错误

0
0

从0开始 独立完成企业级Java电商网站服务端开发

前后端分离,数据库接口设计,架构设计,功能开发,上线运维

9476 学习 · 8804 问题

查看课程