db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: How to read blobs?
Date Thu, 05 Mar 2009 15:33:57 GMT
epdv wrote:
> 
> Hello!
> 
> I want to read blobs in a loop (more exact: the length of the blobs). 
> I'm using a connection with autocommit(true) and a prepared statement 
> with sth. like "select mydata, myblob where mykey=?".
> 
> Then I'm using the following loop:
> 
>     while (rs.next()) {
>         int m = wantedColumnNames.length;
>         Blob blob = (Blob)rs.getObject(x);
>         if (blob == null) {
>             result = 0L;
>         } else {
>             result = blob.length();
>             blob.free();
>         }
>         ...
>     }
> 
> I'm always getting an error message saying that the blob cannot be 
> released after closing, probably the transaction had already been 
> committed. As connection is in autocommit mode, I assume it has already 
> been closed after statement execution, but it I try non-autocommit mode, 
> the resultset is not open after execute (at least derby says that). How 
> can I get the expected result?

Hello Peter,

Can you post the stack traces from the exceptions you get?
That would be nice, so that we can see where the exception is being thrown.
It shouldn't matter, but have you tried using getBlob() instead of 
getObject()?

If possible, posting the runnable code somewhere may also help.


Regards,
-- 
Kristian

> 
> BTW, using derby 10.4.2.0 in client/server mode.
> 
> Kind regards
> 
> Peter
> 


Mime
View raw message