Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 90702 invoked from network); 12 May 2006 07:09:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 May 2006 07:09:27 -0000 Received: (qmail 82911 invoked by uid 500); 12 May 2006 07:09:20 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 82861 invoked by uid 500); 12 May 2006 07:09:19 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 82850 invoked by uid 99); 12 May 2006 07:09:19 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 May 2006 00:09:19 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [203.217.22.128] (HELO file1.syd.nuix.com.au) (203.217.22.128) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 May 2006 00:09:17 -0700 Received: from [192.168.222.102] (demo1.syd.nuix.com.au [192.168.222.102]) by file1.syd.nuix.com.au (Postfix) with ESMTP id 86D31B7625 for ; Fri, 12 May 2006 17:08:44 +1000 (EST) Message-ID: <4464357A.2000900@nuix.com.au> Date: Fri, 12 May 2006 17:12:58 +1000 From: Daniel Noll Organization: NUIX Pty Limited User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) MIME-Version: 1.0 To: Derby Discussion Subject: Re: setBinaryStream References: <000601c67524$b9108d60$6601a8c0@LatitudeD500> In-Reply-To: <000601c67524$b9108d60$6601a8c0@LatitudeD500> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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.