H2数据库:中止查询 [英] H2 Database: Abort Query

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

问题描述

我在嵌入式H2数据库上有一个长期运行的选择查询,希望允许用户取消该查询.

I have a long running select query on an embedded H2 Database and want to allow the user to cancel the query.

这怎么办?我对此一无所获.

How can this be done? I cannot find anything about this.

[更新] 更具体地说,我正在使用JPA运行查询.如何停止查询?

[UPDATE] To be more specific I'm running my query using JPA. How can the query be stopped?

推荐答案

H2支持查询超时设置.您可以在数据库URL中进行如下设置:jdbc:h2:~/db/test;query_timeout=10000. (也许这对您来说不是正确的方法,但对其他阅读此问题的人来说可能是正确的.)

H2 supports a query timeout setting. You can set this in the database URL as follows: jdbc:h2:~/db/test;query_timeout=10000. (Maybe this is not the right approach for you, but it might be for others that read this question.)

您还可以使用 cancel_session函数.但是为此,您需要启用多线程模式,目前不建议将其用于生产环境(在1.3.175版中仍处于试验阶段).

You can also cancel a query running in another connection (session) using the cancel_session function. But for this you need to enable the multi-threaded mode, which is currently not recommended for production use (it is still experimental in version 1.3.175).

这篇关于H2数据库:中止查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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