views:

182

answers:

1

I am investigating using javax.sql.rowset.CachedRowSet in part of my application, however I can only find information on using the proprietary sun implementation com.sun.rowset.CachedRowSetImpl or Oracle specific implementations.

The sun implementation is unsupported and subject to change. Using this could cause also us problems if we want to deploy to non-Sun virtual machines in the future, and finally it leaves unsuppressible warnings in our build logs which can mask other warnings.

Is there an open source alternative implementation that we I can deploy with my application that will work well across multiple databases? At a minimum something that supports MySQL.

+2  A: 

There aren't. The normal practice is namely to map the ResultSet to a List<Row> or Set<Row> yourself and use it further in your application.

List<Row> rows = new ArrayList<Row>();

try {
    // ...
    resultSet = preparedStatement.executeQuery();
    while (resultSet.next()) {
        Row row = new Row();
        row.setColumn1(resultSet.getObject("column1"));
        row.setColumn2(resultSet.getObject("column2"));
        // ...
        rows.add(row);
    }
} finally {
    // ...
}

return rows;

Of course the Row class is here just a Javabean which represents a row of the database table (an entity). The above is just an example, you may name the class and the properties whatever you want. E.g. class User with Long id, String username, String email, Integer age and so on.

BalusC