db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hillegas (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-562) Derby incorrectly throws Exception when streaming to BLOB field
Date Tue, 13 Sep 2005 14:38:56 GMT
    [ http://issues.apache.org/jira/browse/DERBY-562?page=comments#action_12324452 ] 

Rick Hillegas commented on DERBY-562:
-------------------------------------

RawToBinaryFormatStream.checkSufficientData() requires that the InputStream not have any extra
bytes in it. The comment in the code says that the JDBC 3.0 spec requires this behavior. I
couldn't find this assertion in the 3.0 spec when I glanced at it quickly.  However, the javadoc
for java.sql.PreparedStatement.setBinaryStream() says that the length argument is "the number
of bytes in the stream". I suppose someone could interpret this to mean "exactly the number
of bytes in the stream".

I agree that the behavior of the other databases sounds better. I also agree that the error
message is wrong. Holger, can you tell us what other DBMSes you tried?

Can someone cite chapter and verse for the JDBC 3.0 requirement claimed by checkSufficientData()?

> 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


Mime
View raw message