• Post Reply Bookmark Topic Watch Topic
  • New Topic

CachedRowSet out of memory  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello forum,

I have an out of memory-problem with cachedRowSet.

For testing I have tried CachedRowSet on a DB-file with 100-thousands of records and wanted to "page through" it (platform: Windows 7, MySQL Server Version: 5.1.50-community, Driver mysql-connector-java-5.0.4-bin and mysql-connector-java-5.1.8-bin ).

According the Cached Rowset definition there are "chunks" from the database file processsed. This should have the advantage that it is not necessery to load large result sets (I hope I´m right).

In this test: After 4 pages ( 10 records per page) a got an out of memory-Error.

The code segment:

public static void processData2(Connection conn1) {

try {

CachedRowSet crset = new CachedRowSetImpl() {};

crset.setCommand("select * from basicjdbc ");

int i = 0;
while (crset.nextPage()) {
System.out.println("-page " + i + " -------------------");
while (crset.next()) {
System.out.println(crset.getInt(1) + " " + crset.getString(2)
+ " " + crset.getString(3));

} catch (SQLException e) {

The program stops at crset.nextPage():

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.nio.ByteBuffer.wrap(ByteBuffer.java:350)
at java.nio.ByteBuffer.wrap(ByteBuffer.java:373)
at java.lang.StringCoding$StringEncoder.encode(StringCoding.java:237)
at java.lang.StringCoding.encode(StringCoding.java:272)
at java.lang.StringCoding.encode(StringCoding.java:284)
at java.lang.String.getBytes(String.java:986)
at com.mysql.jdbc.MysqlIO.unpackNativeEncodedColumn(MysqlIO.java:3480)
at com.mysql.jdbc.MysqlIO.unpackBinaryResultSetRow(MysqlIO.java:3334)
at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1326)
at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:2262)
at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:439)
at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:1970)
at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1387)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1195)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:693)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1266)
at com.sun.rowset.internal.CachedRowSetReader.readData(CachedRowSetReader.java:202)
at com.sun.rowset.CachedRowSetImpl.nextPage(CachedRowSetImpl.java:7394)
at testCachedRowSet.TestDBprocess.processData2(TestDBprocess.java:82)
at testCachedRowSet.TestDBprocess.main(TestDBprocess.java:41)

This is a very remarkable behavior because it is about processing only some records and some pages....

Does anyone knows the problem and a solution for it?

Or is there a better solution than CachedRowSet (except a where clause)?

Much thanks

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!