简体   繁体   English

如何在java / JDBC中取消postgres查询

[英]How to cancel a postgres query in java/JDBC

How do I cancel a long running postgres query via JDBC or Java? 如何通过JDBC或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. 用例是用户通过前端在postgres数据库上启动查询,但随后他决定并且想要中止/取消当前运行的查询。

Call java.sql.PreparedStatement.cancel() method. 调用java.sql.PreparedStatement.cancel()方法。 Check whether postgres JDBC driver supports this method. 检查postgres JDBC驱动程序是否支持此方法。 As far as I can see from the source code of the latest postgres JDBC driver it does stop the query. 据我所知,从最新的postgres JDBC驱动程序的源代码,它确实停止了查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM