db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikael" <mikael-arons...@telia.com>
Subject PreparedStatement problem with big BLOBS
Date Fri, 21 Sep 2007 14:51:08 GMT
Hi !

I have a pretty weird problem, I use a Derby 10.3.1.4 with the ClientDriver and I run the
code below:

    // Data is a byte[] vector
    ByteArrayInputStream is = new ByteArrayInputStream( data);    
    String sql = "UPDATE MyTable SET FContents=? WHERE FName='" + name + "'";
    PreparedStatement ps = conn.prepareStatement( sql);
    ps.setBinaryStream( 1, is, data.length);
    
    if( ps.executeUpdate() == 0)
    {
        // it throws an exception here if the data array us larger then around 32750 bytes!!!
    }

Connection is "jdbc:derby://localhost/mydb;create=true;"

java.sql.SQLException: A network protocol error was encountered and the connection has been
terminated: A PROTOCOL Data Stream Syntax Error was detected.  Reason: 0x0. Plaintext connection
attempt to an SSL enabled server?
        at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
        at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.executeUpdate(Unknown Source)

The table is defined as:
    CREATE TABLE MyTable (FName varchar(300) NOT NULL,FContents BLOB(16M) NOT NULL)

I do not understand why it only works with small BLOB contents, as soon as I pass 32750 bytes
or so the above happens,
when data is 32750 or smaller it works just fine.

Mime
View raw message