求大神解答问题啊
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 querying database. Cause: java.sql.SQLSyntaxErrorException: 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 ‘WHERE (ID = 0)’ at line 2
The error may exist in com/itcast/ssm/mapper/DocumentMapper.java (best guess)
The error may involve com.itcast.ssm.mapper.DocumentMapper.update-Inline
The error occurred while setting parameters
SQL: UPDATE document_inf WHERE (ID = ?)
Cause: java.sql.SQLSyntaxErrorException: 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 ‘WHERE (ID = 0)’ at line 2
;
bad SQL grammar [];
nested exception is java.sql.SQLSyntaxErrorException: 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 ‘WHERE (ID = 0)’ at line 2
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:660)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Root Cause
org.springframework.jdbc.BadSqlGrammarException:
Error querying database. Cause: java.sql.SQLSyntaxErrorException: 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 ‘WHERE (ID = 0)’ at line 2
The error may exist in com/itcast/ssm/mapper/DocumentMapper.java (best guess)
The error may involve com.itcast.ssm.mapper.DocumentMapper.update-Inline
The error occurred while setting parameters
SQL: UPDATE document_inf WHERE (ID = ?)
Cause: java.sql.SQLSyntaxErrorException: 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 ‘WHERE (ID = 0)’ at line 2
;
bad SQL grammar [];
nested exception is java.sql.SQLSyntaxErrorException: 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 ‘WHERE (ID = 0)’ at line 2
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:73)
org.mybatis.spring.SqlSessionTemplate S q l S e s s i o n I n t e r c e p t o r . i n v o k e ( S q l S e s s i o n T e m p l a t e . j a v a : 446 ) c o m . s u n . p r o x y . SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) com.sun.proxy. SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)com.sun.proxy.Proxy42.selectOne(Unknown Source)
org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)
org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:83)
org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
com.sun.proxy.$Proxy48.update(Unknown Source)
com.itcast.ssm.service.impl.UserServiceImpl.modifyDocument(UserServiceImpl.java:159)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
org.springframework.transaction.interceptor.TransactionInterceptor 1. p r o c e e d W i t h I n v o c a t i o n ( T r a n s a c t i o n I n t e r c e p t o r . j a v a : 99 ) o r g . s p r i n g f r a m e w o r k . t r a n s a c t i o n . i n t e r c e p t o r . T r a n s a c t i o n A s p e c t S u p p o r t . i n v o k e W i t h i n T r a n s a c t i o n ( T r a n s a c t i o n A s p e c t S u p p o r t . j a v a : 282 ) o r g . s p r i n g f r a m e w o r k . t r a n s a c t i o n . i n t e r c e p t o r . T r a n s a c t i o n I n t e r c e p t o r . i n v o k e ( T r a n s a c t i o n I n t e r c e p t o r . j a v a : 96 ) o r g . s p r i n g f r a m e w o r k . a o p . f r a m e w o r k . R e f l e c t i v e M e t h o d I n v o c a t i o n . p r o c e e d ( R e f l e c t i v e M e t h o d I n v o c a t i o n . j a v a : 179 ) o r g . s p r i n g f r a m e w o r k . a o p . f r a m e w o r k . J d k D y n a m i c A o p P r o x y . i n v o k e ( J d k D y n a m i c A o p P r o x y . j a v a : 213 ) c o m . s u n . p r o x y . 1.proceedWithInvocation(TransactionInterceptor.java:99) org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) com.sun.proxy. 1.proceedWithInvocation(TransactionInterceptor.java:99)org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)com.sun.proxy.Proxy49.modifyDocument(Unknown Source)
com.itcast.ssm.controller.DocumentController.updateDocument(DocumentController.java:96)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Root Cause
java.sql.SQLSyntaxErrorException: 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 ‘WHERE (ID = 0)’ at line 2
com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:536)
com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)
com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983)
com.mysql.cj.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1826)
com.mysql.cj.jdbc.PreparedStatement.execute(PreparedStatement.java:1153)
com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:67)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
com.sun.proxy. P r o x y 94. e x e c u t e ( U n k n o w n S o u r c e ) o r g . a p a c h e . i b a t i s . e x e c u t o r . s t a t e m e n t . P r e p a r e d S t a t e m e n t H a n d l e r . q u e r y ( P r e p a r e d S t a t e m e n t H a n d l e r . j a v a : 63 ) o r g . a p a c h e . i b a t i s . e x e c u t o r . s t a t e m e n t . R o u t i n g S t a t e m e n t H a n d l e r . q u e r y ( R o u t i n g S t a t e m e n t H a n d l e r . j a v a : 79 ) o r g . a p a c h e . i b a t i s . e x e c u t o r . S i m p l e E x e c u t o r . d o Q u e r y ( S i m p l e E x e c u t o r . j a v a : 63 ) o r g . a p a c h e . i b a t i s . e x e c u t o r . B a s e E x e c u t o r . q u e r y F r o m D a t a b a s e ( B a s e E x e c u t o r . j a v a : 326 ) o r g . a p a c h e . i b a t i s . e x e c u t o r . B a s e E x e c u t o r . q u e r y ( B a s e E x e c u t o r . j a v a : 156 ) o r g . a p a c h e . i b a t i s . e x e c u t o r . C a c h i n g E x e c u t o r . q u e r y ( C a c h i n g E x e c u t o r . j a v a : 109 ) c o m . g i t h u b . p a g e h e l p e r . P a g e I n t e r c e p t o r . i n t e r c e p t ( P a g e I n t e r c e p t o r . j a v a : 143 ) o r g . a p a c h e . i b a t i s . p l u g i n . P l u g i n . i n v o k e ( P l u g i n . j a v a : 61 ) c o m . s u n . p r o x y . Proxy94.execute(Unknown Source) org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63) org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326) org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:143) org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61) com.sun.proxy. Proxy94.execute(UnknownSource)org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326)org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:143)org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)com.sun.proxy.Proxy92.query(Unknown Source)
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.mybatis.spring.SqlSessionTemplate S q l S e s s i o n I n t e r c e p t o r . i n v o k e ( S q l S e s s i o n T e m p l a t e . j a v a : 433 ) c o m . s u n . p r o x y . SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) com.sun.proxy. SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)com.sun.proxy.Proxy42.selectOne(Unknown Source)
org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)
org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:83)
org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
com.sun.proxy.$Proxy48.update(Unknown Source)
com.itcast.ssm.service.impl.UserServiceImpl.modifyDocument(UserServiceImpl.java:159)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
org.springframework.transaction.interceptor.TransactionInterceptor 1. p r o c e e d W i t h I n v o c a t i o n ( T r a n s a c t i o n I n t e r c e p t o r . j a v a : 99 ) o r g . s p r i n g f r a m e w o r k . t r a n s a c t i o n . i n t e r c e p t o r . T r a n s a c t i o n A s p e c t S u p p o r t . i n v o k e W i t h i n T r a n s a c t i o n ( T r a n s a c t i o n A s p e c t S u p p o r t . j a v a : 282 ) o r g . s p r i n g f r a m e w o r k . t r a n s a c t i o n . i n t e r c e p t o r . T r a n s a c t i o n I n t e r c e p t o r . i n v o k e ( T r a n s a c t i o n I n t e r c e p t o r . j a v a : 96 ) o r g . s p r i n g f r a m e w o r k . a o p . f r a m e w o r k . R e f l e c t i v e M e t h o d I n v o c a t i o n . p r o c e e d ( R e f l e c t i v e M e t h o d I n v o c a t i o n . j a v a : 179 ) o r g . s p r i n g f r a m e w o r k . a o p . f r a m e w o r k . J d k D y n a m i c A o p P r o x y . i n v o k e ( J d k D y n a m i c A o p P r o x y . j a v a : 213 ) c o m . s u n . p r o x y . 1.proceedWithInvocation(TransactionInterceptor.java:99) org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) com.sun.proxy. 1.proceedWithInvocation(TransactionInterceptor.java:99)org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)com.sun.proxy.Proxy49.modifyDocument(Unknown Source)
com.itcast.ssm.controller.DocumentController.updateDocument(DocumentController.java:96)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
Note The full stack trace of the root cause is available in the server logs.
Apache Tomcat/9.0.13
JSP:
controller:
@RequestMapping(value="https://www.it610.com/document/updateDocument")
public ModelAndView updateDocument(
String flag,
@ModelAttribute Document document,
ModelAndView mv){
if(flag.equals(“1”)){
// 根据id查询文档
Document target=userService.findDocumentById(document.getId());
// 设置Model数据
mv.addObject("document", target);
// 设置跳转到修改页面
mv.setViewName("document/showUpdateDocument");
}else{
// 执行修改操作userService.modifyDocument(document);
// 设置客户端跳转到查询请求
mv.setViewName("redirect:/document/selectDocument");
}
// 返回
return mv;
}:
Service:
@Override
public void modifyDocument(Document document) {
documentMapper.update(document);
}
ServiceImpl:
/**
* 修改文档
* @param Document 公告对象
* */
void modifyDocument(Document document);
mapper:
// 动态修改文档
@SelectProvider(type=DocumentDynaSqlProvider.class,method=“updateDocument”)
void update(Document document);
【求大神解答问题啊】DocumentDynaSqlProvider.:
// 动态更新
public String updateDocument(Document document){
return new SQL(){
{
UPDATE(DOCUMENTTABLE);
if(document.getTitle() != null && !document.getTitle().equals("")){
SET("title = #{title}");
}
if(document.getFileName() != null && !document.getFileName().equals("")){
SET("filename = #{fileName}");
}
if(document.getRemark() != null && !document.getRemark().equals("")){
SET("remark = #{remark}");
}
if(document.getUser() != null && document.getUser().getId() != null){
SET("user_id = #{user.id}");
}
WHERE("id = #{id}");
}
}.toString();
}
推荐阅读
- 有句话忍很久了,女生要求买房怎么就物质了()
- 基于爱,才会有“愿望”当“要求”。2017.8.12
- 先放下|先放下 ,求一个好心情
- https请求被提早撤回
- 遇到不正当请求怎么办
- 保姆有偿陪伴(雇主要求过分,保姆没自尊,53岁保姆果断离职)
- 【求助】03
- 发火其实是在求救
- 白色情人节小众提案!有求生欲的boy都进来了
- 萌新求答