H2DB:使用 AND 条件导致本地内存出错

Posted

技术标签:

【中文标题】H2DB:使用 AND 条件导致本地内存出错【英文标题】:H2DB: Using the AND condition causing error in local memory 【发布时间】:2015-03-04 16:18:59 【问题描述】:

我有一个名为分类的表,它有一个名为 product_id 的列和一个名为 node_id 的列。

我正在尝试在 h2 控制台中进行简单查询:

select * from classification 
    where product_id =1 and node_id = 01010101

它给了我以下错误

General error: "java.lang.RuntimeException: Unexpected code path"; SQL statement:
select * from classification where product_id =1 and node_id = 01010101 [50000-164]

使用 和 单独运行语句会产生所需的结果。例如:

select * from classification 
        where product_id =1

只要我放入一个 and 语句,它就会给我这个错误。 H2 文档说明了 AND 条件

值或条件。

例子:

ID=1 AND NAME='嗨'

我不确定我在这里做错了什么。我是否错误地使用了 AND?

堆栈跟踪

select * from classification
where product_ID = 1 AND node_ID = 05051103;
General error: "java.lang.RuntimeException: Unexpected code path"; SQL statement:
select * from classification
where product_ID = 1 AND node_ID = 05051103 [50000-164] HY000/50000 (Help)
org.h2.jdbc.JdbcSQLException: General error: "java.lang.RuntimeException: Unexpected code path"; SQL statement:
select * from classification
where product_ID = 1 AND node_ID = 05051103 [50000-164]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
    at org.h2.message.DbException.get(DbException.java:158)
    at org.h2.message.DbException.convert(DbException.java:281)
    at org.h2.command.Command.executeQuery(Command.java:191)
    at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:173)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:152)
    at org.h2.server.web.WebApp.getResult(WebApp.java:1311)
    at org.h2.server.web.WebApp.query(WebApp.java:1001)
    at org.h2.server.web.WebApp.query(WebApp.java:977)
    at org.h2.server.web.WebApp.process(WebApp.java:217)
    at org.h2.server.web.WebApp.processRequest(WebApp.java:164)
    at org.h2.server.web.WebServlet.doGet(WebServlet.java:118)
    at org.h2.server.web.WebServlet.doPost(WebServlet.java:153)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.processFilterChain(UrlMappingsFilter.java:377)
    at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:244)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:206)
    at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:152)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:69)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:66)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.RuntimeException: Unexpected code path
    at org.h2.message.DbException.throwInternalError(DbException.java:228)
    at org.h2.message.DbException.throwInternalError(DbException.java:241)
    at org.h2.index.MultiVersionCursor.next(MultiVersionCursor.java:135)
    at org.h2.index.IndexCursor.next(IndexCursor.java:238)
    at org.h2.table.TableFilter.next(TableFilter.java:353)
    at org.h2.command.dml.Select.queryFlat(Select.java:513)
    at org.h2.command.dml.Select.queryWithoutCache(Select.java:618)
    at org.h2.command.dml.Query.query(Query.java:297)
    at org.h2.command.dml.Query.query(Query.java:267)
    at org.h2.command.dml.Query.query(Query.java:36)
    at org.h2.command.CommandContainer.query(CommandContainer.java:82)
    at org.h2.command.Command.executeQuery(Command.java:187) 

【问题讨论】:

您使用的是非常旧的 H2 版本(内部版本 164)。你试过更新版本吗?你能发布堆栈跟踪吗? 01010101 只是表中的一个随机值。我在主帖中发布了堆栈跟踪,但我不知道它有多大用处。我没有尝试更新版本,目前我无法控制。 【参考方案1】:

您使用的是非常旧的 H2 版本,即 2007 年的 1.0.64。此问题已通过更新的版本得到修复。

【讨论】:

好吧终于解决了。我不知道我们为什么要使用这么旧的版本。

以上是关于H2DB:使用 AND 条件导致本地内存出错的主要内容,如果未能解决你的问题,请参考以下文章

本地和原始存储库 git 之间没有区别。但是当其他人克隆项目时,在 H2DB 中找不到该表?

异常

为啥会出错啊!???????

本地部署Websphere时出错

手机优酷上下载的视频显示文件损坏怎么回事

如何找出 H2 DB 在内存中运行