码迷,mamicode.com
首页 > 数据库 > 详细

org.springframework.jdbc.BadSqlGrammarException,导入excel表报错问题

时间:2016-05-13 18:50:21      阅读:462      评论:0      收藏:0      [点我收藏+]

标签:

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [ INSERT INTO w_cabinet( ID,Name,Brand,Type,Spec,DeviceNum,Subsystem,BuildingName,Floor,RoomNo,Position,Height,Status,FirstRuntime,Assets) VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ‘DeviceNum‘ in ‘field list‘
 at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233)
 at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
 at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:602)
 at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:811)
 at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:867)
 at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:875)
 at com.ytd.platform.dao.system.DynamicTableHandlerDao.addRecord(DynamicTableHandlerDao.java:128)
 at com.ytd.platform.service.system.DynamicTableHandleService.saveRecord(DynamicTableHandleService.java:58)
 at com.ytd.platform.service.system.DynamicTableHandleService.importFromXls(DynamicTableHandleService.java:166)
 at com.ytd.platform.service.system.DynamicTableHandleService$$FastClassByCGLIB$$17012a41.invoke(<generated>)
 at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
 at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
 at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
 at com.ytd.platform.service.system.DynamicTableHandleService$$EnhancerByCGLIB$$c7a89577.importFromXls(<generated>)
 at com.ytd.platform.controller.wiring.WebCabinetBookController.importXls(WebCabinetBookController.java:363)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:421)
 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:409)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:774)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
 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 com.ytd.core.web.filter.AopFilter.doFilter(AopFilter.java:46)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
 at com.ytd.core.web.filter.EncodingFilter.doFilter(EncodingFilter.java:47)
 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:503)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 at java.lang.Thread.run(Thread.java:744)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ‘DeviceNum‘ in ‘field list‘
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
 at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
 at com.mysql.jdbc.Util.getInstance(Util.java:386)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
 at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
 at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2825)
 at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2156)
 at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2459)
 at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2376)
 at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2360)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at org.logicalcobwebs.proxool.ProxyStatement.invoke(ProxyStatement.java:100)
 at org.logicalcobwebs.proxool.ProxyStatement.intercept(ProxyStatement.java:57)
 at com.mysql.jdbc.Statement$$EnhancerByProxool$$a1052197.executeUpdate(<generated>)
 at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:817)
 at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:1)
 at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:586)
 ... 56 more

 

 

解决方法:

在w_field最后一个字段‘isImport’,不是本表的字段的设置为0。该字段定义为默认值为1,参与导入,当该值为0时,不参与导入库的字段设置。

org.springframework.jdbc.BadSqlGrammarException,导入excel表报错问题

标签:

原文地址:http://www.cnblogs.com/arvin1001/p/5490359.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!