Write data to a smart large object

You can write data to a smart large object in the following ways:
  • Write the data from a byte[ ] buffer to the object.
  • Write the data from a file input stream to the object.
  • Write the data from a file to the object.
Use the IfxLoWrite() methods in the IfxSmartBlob class to write to a smart large object from a byte[ ] buffer or file input stream:
public int IfxLoWrite(int lofd, byte[] buffer) throws SQLException
public int IfxLoWrite(int lofd, InputStream fin, int length) 
   throws SQLException

The first version of the method writes buffer.length bytes of data from the buffer into the smart large object. The second version writes length bytes of data from an InputStream object into the smart large object.

The lofd parameter is a locator file descriptor returned by the IfxLoCreate() or IfxLoOpen() method. The buffer parameter is the byte[] buffer where the data is read. The fin parameter is the InputStream object from which data is written into the smart large object. The length parameter is the number of bytes written into the smart large object. The driver returns the number of bytes written.

Use the IfxLoFromFile() method in the IfxSmartBlob class to write data to a smart large object from a file:
public int IfxLoFromFile (int lofd, String filename, int flag, int 
   offset, int amount) throws SQLException

The lofd parameter is a locator file descriptor returned by the IfxLoCreate() or IfxLoOpen() method. The flag parameter indicates whether the file is on the client or the server. The value is either IfxSmartBlob.LO_CLIENT_FILE or IfxSmartBlob.LO_SERVER_FILE.

The driver returns the number of bytes written.