db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Noll <dan...@nuix.com.au>
Subject Re: setBinaryStream
Date Fri, 12 May 2006 07:12:58 GMT
Todd Wolff wrote:
> Hi,
>  
> Could someone please tell me how I can stream a stream of unkown length 
> to the dbms?  The setBinaryStream method on PreparedStatement requires a 
> length argument and it appears that the Derby impl requires that this 
> value exactly match the number of bytes within the stream. 
>  
> If this is the case, this implies that a client must read the entire 
> stream before passing it off to setBinaryStream? How is this any better 
> than setBytes?

It's better than setBytes because it doesn't require you having all 
those bytes in memory (e.g. imagine if you have 300MB of binary data and 
slightly less available memory.)

I feel your pain, though.

We worked around this situation by having a utility class for writing 
the data into and measuring its length, then exposing an input stream 
over that and feeding that in.  When the data gets too big for us to 
keep in memory, we create a temp file and work from there.  Reading from 
a temp file is still faster than reading from where the input stream 
was, in the majority of cases.

However, problems with that API are Sun's fault.  I wouldn't be 
surprised if someone has already requested a feature request for that 
one -- it would be the best JDBC enhancement ever made, IMO.

Daniel



-- 
Daniel Noll

Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia    Ph: +61 2 9280 0699
Web: http://www.nuix.com.au/                        Fax: +61 2 9212 6902

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.

Mime
View raw message