Tag: 可滚动

如何创建可滚动的ResultSet?

我得到了这个简单的代码来从MSSQL Server 2008中检索记录集,由于我设置了ResultSet.TYPE_SCROLL_INSENSITVE,因此必须可以滚动它,与Javadocs中的示例相同: String qry = “SELECT * from tblPeople”; SQLConnection sql = new SQLConnection(); Statement stmt = sql.getConnection().createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery(qry); 不幸的是,当我想获得像rs.last(); int rowCount = rs.getRow();这样的行数时,我仍然得到了这个Stack Trace rs.last(); int rowCount = rs.getRow(); rs.last(); int rowCount = rs.getRow(); : java.sql.SQLException: ResultSet may only be accessed in a forward direction. at net.sourceforge.jtds.jdbc.JtdsResultSet.checkScrollable(JtdsResultSet.java:304) at […]