NutzCN Logo
问答 h2数据库,数据插入成功,但是报错,怎么避免?
发布于 2925天前 作者 Mr.Hu 2567 次浏览 复制 上一个帖子 下一个帖子
标签:
@Table("article_info")
@Comment("文章信息表")
public class ArticleInfo extends BasePojo {
	private static final long serialVersionUID = 1L;	
	@Id
	@Column("id")
        @Comment("ID")
        @ColDefine(type = ColType.INT, width = 16)
	private long id;

       @Column("author")
       @Comment("作者")
       @ColDefine(type = ColType.VARCHAR, width = 16)
	private String author;
	
	@Column("title")
        @Comment("题目")
        @ColDefine(type = ColType.VARCHAR, width = 128)
	private String title;
	
	@Column("re_time")
        @Comment("登记时间")
        @ColDefine(type = ColType.DATETIME)
	private Date registerTime;
	
	@Column("publication")
        @Comment("刊物")
        @ColDefine(type = ColType.VARCHAR, width = 64)
	private String publication;
	
	@Column("frequencies")
        @Comment("刊期")
        @ColDefine(type = ColType.VARCHAR, width = 32)
	private String frequencies;
	
	@Column("type")
        @Comment("类别")
        @ColDefine(type = ColType.VARCHAR, width = 64)
	private String type;
	
	@Column("all")
        @Comment("全款")
	@ColDefine(type=ColType.FLOAT, width=32, precision=2, notNull=true)
	private BigDecimal all;
	
	@Column("deposit")
        @Comment("定金")
	@ColDefine(type=ColType.FLOAT, width=32, precision=2, notNull=true)
	private BigDecimal deposit;
	
	@Column("spare")
        @Comment("余款")
	@ColDefine(type=ColType.FLOAT, width=32, precision=2, notNull=true)
	private BigDecimal spare;
	
	@Column("deposit_up")
        @Comment("上交定金")
	@ColDefine(type=ColType.FLOAT, width=32, precision=2, notNull=true)
	private BigDecimal depositUp;
	
	@Column("spare_up")
        @Comment("上交余款")
	@ColDefine(type=ColType.FLOAT, width=32, precision=2, notNull=true)
	private BigDecimal spareUp;
	
	@Column("name")
        @Comment("业务员姓名")
        @ColDefine(type = ColType.VARCHAR, width = 16)
	private String name;

错误日志如下:

2016-12-19 16:40:57,510 org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:211) DEBUG - SELECT * FROM sys_menu  WHERE href=? LIMIT 1 OFFSET 0 
    |                    1 |
    |----------------------|
    | /private/article/add |
  For example:> "SELECT * FROM sys_menu  WHERE href='/private/article/add' LIMIT 1 OFFSET 0 "
2016-12-19 16:40:57,524 org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:254) DEBUG - INSERT INTO article_info(author,title,re_time,publication,frequencies,type,all,deposit,spare,deposit_up,spare_up,name,create_time,create_user,is_deleted) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) 
    |  1 |    2 |    3 |  4 |      5 |  6 |    7 |   8 |    9 | 10 | 11 |   12 |                  13 |         14 |    15 |
    |----|------|------|----|--------|----|------|-----|------|---|---|------|---------------------|------------|-------|
    | 张三 | 面朝大海 | NULL | 读者 | 201612 | 励志 | 2000 | 200 | 1800 | 0 | 0 | NULL | 2016-12-19 16:40:57 | superadmin | false |
  For example:> "INSERT INTO article_info(author,title,re_time,publication,frequencies,type,all,deposit,spare,deposit_up,spare_up,name,create_time,create_user,is_deleted) VALUES('张三','面朝大海',NULL,'读者','201612','励志','2000','200','1800','0','0',NULL,'2016-12-19 16:40:57','superadmin',false) "
2016-12-19 16:40:57,526 com.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:147) ERROR - merge sql error, dbType h2, sql : 
INSERT INTO article_info(author,title,re_time,publication,frequencies,type,all,deposit,spare,deposit_up,spare_up,name,create_time,create_user,is_deleted) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) 
com.alibaba.druid.sql.parser.ParserException: syntax error, expect LPAREN, actual COMMA all
	at com.alibaba.druid.sql.parser.SQLExprParser.accept(SQLExprParser.java:1598)
	at com.alibaba.druid.sql.parser.SQLExprParser.parseAll(SQLExprParser.java:597)
	at com.alibaba.druid.sql.parser.SQLExprParser.primary(SQLExprParser.java:563)
	at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.primary(MySqlExprParser.java:167)
	at com.alibaba.druid.sql.parser.SQLExprParser.expr(SQLExprParser.java:124)
	at com.alibaba.druid.sql.parser.SQLExprParser.exprList(SQLExprParser.java:874)
	at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseInsert(MySqlStatementParser.java:1981)
	at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseInsert(MySqlStatementParser.java:191)
	at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:195)
	at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:145)
	at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:140)
	at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:53)
	at com.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:145)
	at com.alibaba.druid.filter.stat.StatFilter.createSqlStat(StatFilter.java:630)
	at com.alibaba.druid.filter.stat.StatFilter.statementPrepareAfter(StatFilter.java:305)
	at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:134)
	at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:459)
	at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:350)
	at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:498)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:261)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:82)
	at org.nutz.dao.impl.DaoSupport$DaoExec.invoke(DaoSupport.java:327)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:38)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:250)
	at org.nutz.dao.impl.DaoSupport$DaoExec.run(DaoSupport.java:317)
	at org.nutz.trans.Trans.exec(Trans.java:174)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:287)
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:50)
	at org.nutz.dao.impl.NutDao.insert(NutDao.java:158)
	at com.bsdkj.cms.modules.service.article.ArtcileInfoService.save(ArtcileInfoService.java:21)
	at com.bsdkj.cms.modules.mvc.article.ArticleInfoAction.addDo(ArticleInfoAction.java:72)
	at com.bsdkj.cms.modules.mvc.article.ArticleInfoAction$$NUTZAOP._aop_invoke(ArticleInfoAction.java:2)
	at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57)
	at com.bsdkj.cms.common.service.log.SysLogAopInterceptor.filter(SysLogAopInterceptor.java:58)
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:60)
	at com.bsdkj.cms.modules.mvc.article.ArticleInfoAction$$NUTZAOP.addDo(ArticleInfoAction.java:1)
	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.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:25)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.bsdkj.cms.common.mvc.processor.NutShiroProcessor.process(NutShiroProcessor.java:54)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.bsdkj.cms.common.mvc.processor.XSSProcessor.process(XSSProcessor.java:43)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.bsdkj.cms.common.mvc.processor.GlobalsSettingProcessor.process(GlobalsSettingProcessor.java:31)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at com.bsdkj.cms.common.mvc.processor.LogTimeProcessor.process(LogTimeProcessor.java:21)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:196)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at com.bsdkj.cms.common.mvc.filter.XssFilter.doFilter(XssFilter.java:23)
	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$AbstractConnectionHandler.process(AbstractProtocol.java:625)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
2 回复

是druid解析SQL的bug哦, 可以给它报个issue

可选解决办法之一: dao.js里面dataSource的配置中, filters不使用mergeStat, 改为使用普通的stat

好的,谢谢兽总!

添加回复
请先登陆
回到顶部