Create a smart large object
This example illustrates the steps shown in Creating smart large objects.
file = new File("data.dat"); FileInputStream fin = new FileInputStream(file); byte[] buffer = new byte[200];; IfxLobDescriptor loDesc = new IfxLobDescriptor(myConn); IfxLocator loPtr = new IfxLocator(); IfxSmartBlob smb = new IfxSmartBlob(myConn); // Now create the large object in server. Read the data from the file // data.dat and write to the large object. int loFd = smb.IfxLoCreate(loDesc, smb.LO_RDWR, loPtr); System.out.println("A smart-blob is created "); int n = fin.read(buffer); if (n > 0) n = smb.IfxLoWrite(loFd, buffer); System.out.println("Wrote: " + n +" bytes into it"); // Close the large object and release the locator. smb.IfxLoClose(loFd); System.out.println("Smart-blob is closed " ); smb.IfxLoRelease(loPtr); System.out.println("Smart Blob Locator is released ");
The contents of the file data.dat are written to the smart large object.