如何在Java/JDBC中取消Postgres查询 [英] How to cancel a postgres query in java/JDBC

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

问题描述

如何通过JDBC或Java取消长期运行的postgres查询?

How do I cancel a long running postgres query via JDBC or Java?

用例是用户在postgres数据库上启动查询 通过前端,但随后他做出其他决定,并希望 中止/取消当前正在运行的查询.

The usecase would be that an user starts a query on a postgres database via a front end, but then he decides otherwise and wants to abort/cancel the currently running query.

推荐答案

调用java.sql.PreparedStatement.cancel()方法.检查postgres JDBC驱动程序是否支持此方法.据我从最新的postgres JDBC驱动程序的源代码中看到的,它确实停止了查询.

Call java.sql.PreparedStatement.cancel() method. Check whether postgres JDBC driver supports this method. As far as I can see from the source code of the latest postgres JDBC driver it does stop the query.

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

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