Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 10664 invoked from network); 19 Sep 2005 20:48:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Sep 2005 20:48:35 -0000 Received: (qmail 90549 invoked by uid 500); 19 Sep 2005 20:48:33 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 90512 invoked by uid 500); 19 Sep 2005 20:48:33 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Development" Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 90499 invoked by uid 99); 19 Sep 2005 20:48:33 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=SPF_FAIL X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Sep 2005 13:48:32 -0700 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id B1114125 for ; Mon, 19 Sep 2005 22:48:28 +0200 (CEST) Message-ID: <212437262.1127162908722.JavaMail.jira@ajax.apache.org> Date: Mon, 19 Sep 2005 22:48:28 +0200 (CEST) From: "Sunitha Kambhampati (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-562) Derby incorrectly throws Exception when streaming to BLOB field In-Reply-To: <672715523.1126607934399.JavaMail.jira@ajax.apache.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 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 [ http://issues.apache.org/jira/browse/DERBY-562?page=comments#action_12329903 ] Sunitha Kambhampati commented on DERBY-562: ------------------------------------------- As Dan also pointed out in the earlier comment, Derby behavior is correct according to what the jdbc spec says ( in this case the tutorial book). e.g. ps.setBinaryStream(pos,stream, streamLength) Right now, even if you pass a stream with length greater than streamLength , derby throws an exception with the following message "Input stream held less data than requested length" I think the message must be changed to correctly say - "Input stream did not have the exact amount of data as the requested length." I will submit a patch for this. > Derby incorrectly throws Exception when streaming to BLOB field > --------------------------------------------------------------- > > Key: DERBY-562 > URL: http://issues.apache.org/jira/browse/DERBY-562 > Project: Derby > Type: Bug > Versions: 10.1.1.0 > Reporter: Holger Rehn > > Derby incorrectly throws an Exception when streaming to a BLOB in case the used InputStream actually could provide more data than I want to write to the BLOB field. > PreparedStatement statement = connection.prepareStatement( "insert into FOO(ID,DATA) values(?, ?)" ); > statement.setLong( 1, someValue ); > statement.setBinaryStream( 2, someInputStream, amountOfData ); // amountOfData < amount of data readable from someInputStream > statement.executeUpdate(); > executeUpdate() throws an SQLException with detail message: "Input stream held less data than requested length.: java.io.IOException" > In my case this was first caused by writing an internal buffer (byte[]) to the data base through a ByteArrayInputStream while not limiting the ByteArrayInputStream to the useful data within the buffer but setting amountOfData to the number of useful bytes. So the 2 problems are: > 1. the error text is definitly incorrect since I provide more data than neccessary, not less > 2. in my opinion this shouldn't throw an exception at all (I checked against 4 other DBMS, all of them worked as intended) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira