我正在使用最新的derby10.11.1.1。 做这样的事情:如何停止正在进行的java.sql.statement.executeQuery()?
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中实现,我需要使用不同的嵌入式数据库?任何提示一些免费的数据库,我可以使用,而不是德比,哪些会支持SQL超时?
请出示您的实际代码,而不是“像”了。如果没有完整的背景,很难诊断问题。请阅读“[问]”了解更多详情。 –
h2支持查询超时:http://stackoverflow.com/q/21984515/217324 –
@DougR。我的实际代码稍长一些。你错过了哪些信息?恐怕德比根本不支持cancel()。我发现[参考手册页](http://db.apache.org/derby/docs/10.11/ref/rrefexcept71493.html),其中写有'cancel()不被服务器支持.'所以剩下的问题就是如何解锁不需要cancel()的derby查询,还可以使用其他嵌入式数据库(可以使用cancel())。 –