我有一个运行任务的线程池,主要使用 JDBC 查询 Postgresql。如果取消已提交任务的 future 会取消任何正在进行的查询,那将很方便。是否有捷径可寻?它只适用于 Postgresql。
最佳答案
你可以使用 Statement.cancel() :
Cancels this Statement object if both the DBMS and driver support aborting an SQL statement. This method can be used by one thread to cancel a statement that is being executed by another thread.
cancel()
在 PostgreSQL JDBC 驱动程序中实现(s. PgStatement)
关于java - 如何中断使用 Postgresql 运行 JDBC 查询的线程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45184787/