【发布时间】:2015-05-19 16:49:49
【问题描述】:
我正在使用最新的 derby10.11.1.1。 做这样的事情:
DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver())
java.sql.Connection connection = DriverManager.getConnection("jdbc:derby:filePath", ...)
Statement stmt = connection.createStatement();
stmt.setQueryTimeout(2); // shall stop query after 2 seconds but id does nothing
stmt.executeQuery(strSql);
stmt.cancel(); // this in fact would run in other thread
我收到异常"java.sql.SQLFeatureNotSupportedException: Caused by: ERROR 0A000: Feature not implemented: cancel"
你知道是否有办法让它工作吗?或者它真的没有在 Derby 中实现,我需要使用不同的嵌入式数据库?关于一些免费数据库的任何提示,我可以使用它来代替 derby 并且支持 SQL 超时?
【问题讨论】:
-
请显示您的实际代码,而不是“类似”它。如果没有完整的上下文,很难诊断问题。请阅读“How to Ask”了解更多详情。
-
h2 支持查询超时:stackoverflow.com/q/21984515/217324
-
@DougR。我的实际代码有点长。你缺少什么信息?恐怕 Derby 根本不支持 cancel()。我找到了reference manual page
cancel() not supported by the server.写在哪里所以剩下的问题是如何在没有 cancel() 的情况下解锁 derby 查询,或者使用什么可以取消的嵌入式数据库。 -
因此,如果它不违反任何保密协议,请发布您的实际代码或导致错误的minimal, complete, and verifiable example。