The problem: we are
getting a SQLWarning "Part Longdata_C not handled" when storing a binary stream
with length greater than the configured _PACKET_SIZE support parameter at the
SAPDB server. The result is, we cannot store reliable binary data larger than
the _PACKET_SIZE.
What is going wrong
?
The code we use in
an EJB component to store the byte array is:
- public Long ejbCreate(byte[] longBinaryData)
- throws CreateException
- {
- // set the attributes of this entity
- resetRefs();
- this.ID = computeNewID();
- this.longBinaryData = longBinaryData;
- // create the associated database row
- Connection conn = null;
- PreparedStatement ps = null;
- try
- {
- // get the current connection to the data source
- conn = getConnection();
- // prepare the INSERT statement
- ps = conn.prepareStatement("INSERT INTO tableWithLongBinaryData (ID,longBinaryData) VALUES (?,?)");
- // set max field size to unlimited
- ps.setMaxFieldSize(0);
- // set statement argument values
- ps.setObject(1, this.ID, Types.BIGINT);
- InputStream in = new ByteArrayInputStream(this.longBinaryData);
- ps.setBinaryStream(2, in, this.longBinaryData.length);
- // execute the statement
- if (ps.executeUpdate() != 1)
- {
- throw new CreateException();
- }
- // dump warnings to log
- SQLWarning warning = ps.getWarnings();
- while (warning != null)
- {
- warning.printStackTrace();
- warning = warning.getNextWarning();
- }
- }
- catch (SQLException e)
- {
- throw new CreateException(e.getMessage());
- }
- finally
- {
- try
- {
- if (ps != null) ps.close();
- if (conn != null) conn.close();
- }
- catch (SQLException e) {}
- }
- // return primary key of created row
- return this.ID;
- }
Best
Regards,
Marcel
Wagner
