I'm trying to implement a database paging solution (forward only required) using a CachedRowSet
to page an AS400JDBCResultSet
containing the results of my query.
I've tried using the
CachedRowSet cachedRowSet = new CachedRowSetImpl();
cachedRowSet.setMaxRows(10);
cachedRowSet.setPageSize(10);
cachedRowSet.populate(resultSet);
approach, but the full result set (65 records) is returned in the first page (i.e. by calling cachedRowSet.next()
). I've also tried the
CachedRowSet cachedRowSet = new CachedRowSetImpl();
cachedRowSet.setPageSize(10);
cachedRowSet.setMaxRows(0);
cachedRowSet.setUsername("username");
cachedRowSet.setPassword("password");
cachedRowSet.setUrl("jdbc:as400://dev;naming=system;libraries=*LIBL;prompt=false;");
cachedRowSet.setCommand(query);
cachedRowSet.execute(connection);
approach, but I get the following exception thrown on the execute()
call
Exception in thread "main" java.lang.AbstractMethodError: java/sql/DatabaseMetaData.locatorsUpdateCopy()Z
at com.sun.rowset.CachedRowSetImpl.initMetaData(CachedRowSetImpl.java:712)
at com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:617)
at com.sun.rowset.internal.CachedRowSetReader.readData(CachedRowSetReader.java:190)
at com.sun.rowset.CachedRowSetImpl.execute(CachedRowSetImpl.java:756)
I've tried on both IBM & Sun JREs.
Any ideas? Is this functionality just plain not supported by my JDBC driver?
Update: Also happens with MySQL driver - so I must be doing something else wrong, right?
Update (2): Have got it to work on Java 5.0 & 6.0 for MySql's Driver
, but only on 6.0 for my AS400JDBCDriver
- both using method 2 from above. Seems to be quite slow in any case.