db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cory Tucker" <cory.tuc...@gmail.com>
Subject getBytes() or getBlob() fails when resultSet is larger than 1
Date Sat, 06 Jan 2007 01:08:22 GMT
Hi,

I am relatively new to using Blob's, so I hope that it is user error
and not a bug in Derby.

I have a table created like so:

"CREATE table " + TABLE_NAME + " (" +
"    ID          INTEGER NOT NULL " +
"                PRIMARY KEY GENERATED ALWAYS AS IDENTITY " +
"                (START WITH 1, INCREMENT BY 1)," +
"    Title             VARCHAR(50), " +
"    Synopsis     VARCHAR(1024), " +
"    Rating         FLOAT, " +
"    Icon            BLOB(1024K) )";



My problem is when I execute a query on the table which returns only
one result, I can get the blob data no problem. However, when I
execute a query that returns a result set with more than one result,
the second time the getBlob() or getBytes() method is called it throws
a SQLException and gives the following error:

ERROR XCL30: An IOException was thrown when reading a 'BLOB' from an
InputStream.


Here is a snippet of the code I am using:

try {
  Statement statement = connection.createStatement();
  ResultSet results = statement.executeQuery("SELECT * FROM " + TABLE_NAME);
  while (results.next()) {
    MyObject o;
    ...
    o.setField(results.getBytes("Icon"));
    ...
  }
  results.close();
  statement.close();
} catch (SQLException e) {...}

The data doesn't seem to be the problem because when I execute a query
to specifically get one of the entries (not necessarily the first
one), then it works just fine.

Does anyone know what might be going wrong?

thanks
--Cory
cory.tucker@gmail.com

Mime
View raw message