db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <Richard.Hille...@Sun.COM>
Subject Re: How to read blobs?
Date Thu, 05 Mar 2009 16:27:13 GMT
Hi Peter,

If all you need is the lengths of the blobs, then you could use the 
length() function:

select length( blobColumn ) from myTable

For null blobs, the returned value will be null.

Hope this helps,
-Rick

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?
>
> BTW, using derby 10.4.2.0 in client/server mode.
>
> Kind regards
>
> Peter
>


Mime
View raw message