如何中止/取消HSQLDB查询 [英] How to abort/cancel HSQLDB query

查看:98
本文介绍了如何中止/取消HSQLDB查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Hibernate提供的JPA的Java SE应用程序和一个HSQL数据库.该应用程序使用EntityManagers查询数据库以获取信息,以便在屏幕上绘制图表.在执行查询时,图表区域具有典型的旋转图标,以使用户知道其正在工作.一些查询需要很长时间,并且我想具有中止/取消查询的功能.我知道我可以解开EntityManager并获取Hibernate会话并调用cancelQuery(),但这不会做任何事情,因为HSQLDB驱动程序不支持Statement接口(

I have a Java SE application using JPA provided by Hibernate and a HSQL database. The application queries the database with EntityManagers for information in order to draw charts on the screen. While the query is executing, the area for the chart has the typical spinning icon to let the user know that it's working. Some queries take a long time, and I want to have the feature to abort/cancel the query. I know I can unwrap the EntityManager and get the Hibernate Session and call cancelQuery(), but that doesn't do anything because the HSQLDB driver doesn't support the cancel() method on the Statement interface (http://hsqldb.org/doc/2.0/apidocs/org/hsqldb/jdbc/JDBCStatement.html#cancel()). Is there another way either through API or redesigning my app? Not being able to cancel a running query is a nuisance.

推荐答案

目前还没有办法结束HSQLDB服务器上长时间运行的语句. Fredt提供的ALTER SESSION方法似乎不适用于2.3.4的当前RC2(以及svn修订版5511),它只会导致事务回滚:select语句完成工作后,序列化失败.因此,解决此问题的唯一方法是设置超时.不过,这不是实际的解决方案.

At the Moment there is no way to end a long-running Statement on a HSQLDB Server. The ALTER SESSION Method provided by Fredt does not seem to work in the current RC2 for 2.3.4 (and also in the svn revision 5511), it just leads to a transaction rollback:serialization failure AFTER the select statement has finished working. So the only way to deal with this Problem is setting the Timeout. This is not an actual Solution to the Problem, though.

更新:在SVN信息库(Rev. 5627)中最新的HSQLDB版本和即将发布的2.3.4版本中,现在实现了立即取消语句的可能性.还有一个新的方法,ALTER SESSSION END STATEMENT,它可以在不回滚的情况下中止事务.请参阅 https://sourceforge.net/p/hsqldb/bugs/1436/详细信息.

Update: In the newest Version of HSQLDB in the SVN Repository (Rev. 5627) and in the upcoming 2.3.4 Release, the possibility to cancel a statement immediately is now implemented. There also is a new Method, ALTER SESSSION END STATEMENT, that can abort a transaction without a rollback. See https://sourceforge.net/p/hsqldb/bugs/1436/ for details.

这篇关于如何中止/取消HSQLDB查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆