新手练习|javeEE初学者错误记录

程序报错如下
Servlet.service() for servlet [DispatcherServlet] in context with path [/WZNoteServer] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException:
Error updating database. Cause: java.sql.SQLSyntaxErrorException: Unknown column ‘user_id’ in ‘field list’
The error may exist in file [D:\学习\eclipsesettings\apache-tomcat-7.0.67\wtpwebapps\WZNoteServer\WEB-INF\classes\mapper\JFMapper.xml]
The error may involve com.whc.noteserver.dao.JFDao.addJF-Inline
The error occurred while setting parameters
SQL: insert into note_t_jf (id,jf,user_id) values(?,?,?)
Cause: java.sql.SQLSyntaxErrorException: Unknown column ‘user_id’ in ‘field list’
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Unknown column ‘user_id’ in ‘field list’] with root cause
java.sql.SQLSyntaxErrorException: Unknown column ‘user_id’ in ‘field list’
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370)
at org.apache.commons.dbcp2.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:94)
at org.apache.commons.dbcp2.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
at com.sun.proxy. P r o x y 52. e x e c u t e ( U n k n o w n S o u r c e ) a t 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 . u p d a t e ( 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 : 47 ) a t 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 . u p d a t e ( 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 : 74 ) a t 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 U p d a t e ( S i m p l e E x e c u t o r . j a v a : 50 ) a t 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 . u p d a t e ( B a s e E x e c u t o r . j a v a : 117 ) a t 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 . u p d a t e ( C a c h i n g E x e c u t o r . j a v a : 76 ) a t o r g . a p a c h e . i b a t i s . s e s s i o n . d e f a u l t s . D e f a u l t S q l S e s s i o n . u p d a t e ( D e f a u l t S q l S e s s i o n . j a v a : 197 ) a t o r g . a p a c h e . i b a t i s . s e s s i o n . d e f a u l t s . D e f a u l t S q l S e s s i o n . i n s e r t ( D e f a u l t S q l S e s s i o n . j a v a : 184 ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v e M e t h o d ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( U n k n o w n S o u r c e ) a t s u n . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( U n k n o w n S o u r c e ) a t j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( U n k n o w n S o u r c e ) a t o r g . m y b a t i s . s p r i n g . S q l S e s s i o n T e m p l a t e Proxy52.execute(Unknown Source) at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197) at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.mybatis.spring.SqlSessionTemplate Proxy52.execute(UnknownSource)atorg.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47)atorg.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)atorg.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)atorg.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)atorg.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)atorg.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)atorg.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.mybatis.spring.SqlSessionTemplateSqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
at com.sun.proxy. P r o x y 34. i n s e r t ( U n k n o w n S o u r c e ) a t o r g . m y b a t i s . s p r i n g . S q l S e s s i o n T e m p l a t e . i n s e r t ( S q l S e s s i o n T e m p l a t e . j a v a : 271 ) a t o r g . a p a c h e . i b a t i s . b i n d i n g . M a p p e r M e t h o d . e x e c u t e ( M a p p e r M e t h o d . j a v a : 62 ) a t o r g . a p a c h e . i b a t i s . b i n d i n g . M a p p e r P r o x y Proxy34.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:271) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62) at org.apache.ibatis.binding.MapperProxy Proxy34.insert(UnknownSource)atorg.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:271)atorg.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)atorg.apache.ibatis.binding.MapperProxyPlainMethodInvoker.invoke(MapperProxy.java:144)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85)
at com.sun.proxy. P r o x y 40. a d d J F ( U n k n o w n S o u r c e ) a t c o m . w h c . n o t e s e r v e r . s e r v i c e i m p l . U s e r I m p l . a d d U s e r ( U s e r I m p l . j a v a : 45 ) a t c o m . w h c . n o t e s e r v e r . c o n t r o l l e r . U s e r C o n t r o l l e r . r e g i s t e r ( U s e r C o n t r o l l e r . j a v a : 51 ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v e M e t h o d ) a t s u n . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( U n k n o w n S o u r c e ) a t s u n . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( U n k n o w n S o u r c e ) a t j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( U n k n o w n S o u r c e ) a t o r g . s p r i n g f r a m e w o r k . w e b . m e t h o d . s u p p o r t . I n v o c a b l e H a n d l e r M e t h o d . d o I n v o k e ( I n v o c a b l e H a n d l e r M e t h o d . j a v a : 190 ) a t o r g . s p r i n g f r a m e w o r k . w e b . m e t h o d . s u p p o r t . I n v o c a b l e H a n d l e r M e t h o d . i n v o k e F o r R e q u e s t ( I n v o c a b l e H a n d l e r M e t h o d . j a v a : 138 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . m v c . m e t h o d . a n n o t a t i o n . S e r v l e t I n v o c a b l e H a n d l e r M e t h o d . i n v o k e A n d H a n d l e ( S e r v l e t I n v o c a b l e H a n d l e r M e t h o d . j a v a : 106 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . m v c . m e t h o d . a n n o t a t i o n . R e q u e s t M a p p i n g H a n d l e r A d a p t e r . i n v o k e H a n d l e r M e t h o d ( R e q u e s t M a p p i n g H a n d l e r A d a p t e r . j a v a : 879 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . m v c . m e t h o d . a n n o t a t i o n . R e q u e s t M a p p i n g H a n d l e r A d a p t e r . h a n d l e I n t e r n a l ( R e q u e s t M a p p i n g H a n d l e r A d a p t e r . j a v a : 793 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . m v c . m e t h o d . A b s t r a c t H a n d l e r M e t h o d A d a p t e r . h a n d l e ( A b s t r a c t H a n d l e r M e t h o d A d a p t e r . j a v a : 87 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . D i s p a t c h e r S e r v l e t . d o D i s p a t c h ( D i s p a t c h e r S e r v l e t . j a v a : 1040 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . D i s p a t c h e r S e r v l e t . d o S e r v i c e ( D i s p a t c h e r S e r v l e t . j a v a : 943 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . p r o c e s s R e q u e s t ( F r a m e w o r k S e r v l e t . j a v a : 1006 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . d o P o s t ( F r a m e w o r k S e r v l e t . j a v a : 909 ) a t j a v a x . s e r v l e t . h t t p . H t t p S e r v l e t . s e r v i c e ( H t t p S e r v l e t . j a v a : 650 ) a t o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . F r a m e w o r k S e r v l e t . s e r v i c e ( F r a m e w o r k S e r v l e t . j a v a : 883 ) a t j a v a x . s e r v l e t . h t t p . H t t p S e r v l e t . s e r v i c e ( H t t p S e r v l e t . j a v a : 731 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . A p p l i c a t i o n F i l t e r C h a i n . i n t e r n a l D o F i l t e r ( A p p l i c a t i o n F i l t e r C h a i n . j a v a : 303 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . A p p l i c a t i o n F i l t e r C h a i n . d o F i l t e r ( A p p l i c a t i o n F i l t e r C h a i n . j a v a : 208 ) a t o r g . a p a c h e . t o m c a t . w e b s o c k e t . s e r v e r . W s F i l t e r . d o F i l t e r ( W s F i l t e r . j a v a : 52 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . A p p l i c a t i o n F i l t e r C h a i n . i n t e r n a l D o F i l t e r ( A p p l i c a t i o n F i l t e r C h a i n . j a v a : 241 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . A p p l i c a t i o n F i l t e r C h a i n . d o F i l t e r ( A p p l i c a t i o n F i l t e r C h a i n . j a v a : 208 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d W r a p p e r V a l v e . i n v o k e ( S t a n d a r d W r a p p e r V a l v e . j a v a : 220 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d C o n t e x t V a l v e . i n v o k e ( S t a n d a r d C o n t e x t V a l v e . j a v a : 122 ) a t o r g . a p a c h e . c a t a l i n a . a u t h e n t i c a t o r . A u t h e n t i c a t o r B a s e . i n v o k e ( A u t h e n t i c a t o r B a s e . j a v a : 505 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d H o s t V a l v e . i n v o k e ( S t a n d a r d H o s t V a l v e . j a v a : 169 ) a t o r g . a p a c h e . c a t a l i n a . v a l v e s . E r r o r R e p o r t V a l v e . i n v o k e ( E r r o r R e p o r t V a l v e . j a v a : 103 ) a t o r g . a p a c h e . c a t a l i n a . v a l v e s . A c c e s s L o g V a l v e . i n v o k e ( A c c e s s L o g V a l v e . j a v a : 956 ) a t o r g . a p a c h e . c a t a l i n a . c o r e . S t a n d a r d E n g i n e V a l v e . i n v o k e ( S t a n d a r d E n g i n e V a l v e . j a v a : 116 ) a t o r g . a p a c h e . c a t a l i n a . c o n n e c t o r . C o y o t e A d a p t e r . s e r v i c e ( C o y o t e A d a p t e r . j a v a : 423 ) a t o r g . a p a c h e . c o y o t e . h t t p 11. A b s t r a c t H t t p 11 P r o c e s s o r . p r o c e s s ( A b s t r a c t H t t p 11 P r o c e s s o r . j a v a : 1079 ) a t o r g . a p a c h e . c o y o t e . A b s t r a c t P r o t o c o l Proxy40.addJF(Unknown Source) at com.whc.noteserver.serviceimpl.UserImpl.addUser(UserImpl.java:45) at com.whc.noteserver.controller.UserController.register(UserController.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) at org.apache.coyote.AbstractProtocol Proxy40.addJF(UnknownSource)atcom.whc.noteserver.serviceimpl.UserImpl.addUser(UserImpl.java:45)atcom.whc.noteserver.controller.UserController.register(UserController.java:51)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)atorg.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)atorg.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)atorg.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)atorg.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)atorg.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)atorg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)atorg.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:650)atorg.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:731)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)atorg.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)atorg.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)atorg.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)atorg.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)atorg.apache.coyote.AbstractProtocolAbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint S o c k e t P r o c e s s o r . r u n ( J I o E n d p o i n t . j a v a : 318 ) a t j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r . r u n W o r k e r ( U n k n o w n S o u r c e ) a t j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r SocketProcessor.run(JIoEndpoint.java:318) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor SocketProcessor.run(JIoEndpoint.java:318)atjava.util.concurrent.ThreadPoolExecutor.runWorker(UnknownSource)atjava.util.concurrent.ThreadPoolExecutorWorker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
仔细查看
发现下面还有提示
Error updating database. Cause: java.sql.SQLSyntaxErrorException: Unknown column ‘user_id’ in ‘field list’
The error may exist in file [D:\学习\eclipsesettings\apache-tomcat-7.0.67\wtpwebapps\WZNoteServer\WEB-INF\classes\mapper\JFMapper.xml]
The error may involve com.whc.noteserver.dao.JFDao.addJF-Inline
The error occurred while setting parameters
SQL: insert into note_t_jf (id,jf,user_id) values(?,?,?)
Cause: java.sql.SQLSyntaxErrorException: Unknown column ‘user_id’ in ‘field list’
【新手练习|javeEE初学者错误记录】原理是数据库内名称写错了,更改后即可运行

    推荐阅读