This class implements the large object interface to Red Hat Database. It provides the basic methods required to run the interface plus a pair of methods that provide InputStream and OutputStream classes for this object.
Normally, client code would use the getAsciiStream, getBinaryStream, or getUnicodeStream methods in ResultSet, setAsciiStream, setBinaryStream, or setUnicodeStream methods in PreparedStatement to access Large Objects. Sometimes, however, lower level access to Large Objects is required beyond what is supported by the JDBC specification.
Refer to LargeObjectManager on how to gain access to LargeObject objects.
package org.postgresql.largeobject; public class LargeObject { // Constants public static final int SEEK_SET; public static final int SEEK_CUR; public static final int SEEK_END; // Methods public void close() throws SQLException; public int getOID(); public byte[] read(int len) throws SQLException; public void read(byte buf[], int off, int len) throws SQLException; public void write(byte buf[]) throws SQLException; public void write(byte buf[], int off, int len) throws SQLException; } |
Indicates a seek from the beginning of a file.
Indicates a seek from the current position.
Indicates a seek from the end of a file.
This method closes the object. You must not call methods of the object after this method is invoked.
Returns the OID of this LargeObject.
Read a certain amount of data from the large object, starting at the beginning, and return it as an array of bytes.
Parameters.
Number of bytes to read.
Read a certain amount of data from the large object, starting at the given offset, into the given byte array.
Parameters.
array to read bytes into
offset to start reading from
number of bytes to read
Write some data to the large object.
Parameters.
source data
Write a certain amount of data to the large object, starting at a given offset.
Parameters.
source data
offset to start writing at
number of bytes to write
This class implements the large object interface to Red Hat Database. It provides methods that allow client code to create, open, and delete large objects from the database. Opening a LOB returns an instance of org.postgresql.largeobject.LargeObject.
This class can only be created by org.postgresql.Connection. To get access to this class, use the following segment of code:
import org.postgresql.Connection; import org.postgresql.largeobject.*; Connection con; LargeObjectManager lobj; // ... code that opens a connection ... lobj = ((org.postgresql.Connection) con).getLargeObjectAPI(); |
package org.postgresql.largeobject; public class LargeObjectManager { // Constants public static final int WRITE; public static final int READ; public static final int READWRITE; // Methods public LargeObject open(int oid) throws SQLException; public LargeObject open(int oid, int mode) throws SQLException; public int create() throws SQLException; public int create(int mode) throws SQLException; public void delete(int oid) throws SQLException; public void unlink(int oid) throws SQLException; } |
This mode indicates we want to write to an object.
This mode indicates we want to read an object.
This mode is the default. It indicates we want read and write access to a large object.
Create a new LOB in the database. The access mode of the new LOB is set to READWRITE.
Returns. OID of the new LOB.
Create a new LOB in the database with the given access mode.
Parameters.
Access mode to use for the new LOB.
Returns. OID of the new LOB.
Delete the indicated LOB from the database.
Parameters.
OID of the LOB to delete.
Open the LOB indicated by the parameter oid. The access mode is set to READWRITE.
Parameters.
The OID of the LOB to open.
Returns. The LargeObject object that represents the opened LOB.
Parameters.
The OID of the LOB to open.
The access mode to use.
Returns. The LargeObject object that represents the opened LOB.
Deletes the indicated LOB from the database. It is identical to the delete method but is supplied because the equivalent C API (libpq) uses "unlink".