0
每当我尝试获取ResultSet时,都会收到此错误。我在网上看了很长时间,并且有很多poeple和我一样得到同样的问题,但是他们的问题是他们使用PreparedStatement进行多个查询。ResultSet关闭错误后即使PreparedStatement仅使用一次也不允许操作
正如你在下面的代码中看到的,我只使用了PreparedStatement一次。
getSQLConnection()方法返回一个全新的Connection。 将引发错误就行了:结果集RS = ps.executeQuery()
try (Connection connection = getSQLConnection();
PreparedStatement ps = connection.prepareStatement(qry);
ResultSet rs = ps.executeQuery()) {
return rs;
} catch (SQLException ex) {
plugin.get().getLogger().log(Level.SEVERE, "Couldn't execute SQL statement: ", ex);
}
我已经使用SQL数据库之前也从来没有这样做过。我很困惑。希望你们能帮助我!