0

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.

Harry Lime
  • 29,476
  • 4
  • 31
  • 37

2 Answers2

0

It sounds like your driver may not be JDBC 3.0 compliant, which is when rowsets were introduced to the API. The AbstractMethodError supports this.

Check your driver documentation to see which JDBC version it claims to support.

skaffman
  • 398,947
  • 96
  • 818
  • 769
  • The jar containing the driver has a class AS400JDBCRowSet, so I'd imagine this is not the problem. Also, we managed to get it to work with a 6.0 JRE & the same Driver. Thanks though :) – Harry Lime Jun 12 '09 at 14:37
-2

The way that the drivers are called have changed with the newer versions of Java. The old school had extra boiler-plate, but it still works with Java 6.

Connection c = null;
try {
        Class.forName(driverString);
    } catch (ClassNotFoundException e) {
        //TODO
    }
c = DriverManager.getConnection(url, username, password);
bluish
  • 26,356
  • 27
  • 122
  • 180
WolfmanDragon
  • 7,851
  • 14
  • 49
  • 61