This class 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, or setAsciiStream, setBinaryStream, or setUnicodeStream methods in PreparedStatement to access Large Objects.
However, sometimes lower level access to Large Objects are required, that are not supported by the JDBC specification.
Refer to org.postgresql.largeobject.LargeObjectManager on how to gain access to a Large Object, or how to create one.
org.postgresql.largeobject.LargeObjectManager , java.sql.ResultSet#getAsciiStream , java.sql.ResultSet#getBinaryStream , java.sql.ResultSet#getUnicodeStream , java.sql.PreparedStatement#setAsciiStream , java.sql.PreparedStatement#setBinaryStream , java.sql.PreparedStatement#setUnicodeStream
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private final boolean | |
| private @Nullable BaseConnection | |
| private static final byte[] | |
| private final int | |
| private final Fastpath | |
| private final int | |
| private final long | |
| private @Nullable BlobOutputStream | |
| public static final int | SEEK_CUR
Indicates a seek from the current position. |
| public static final int | SEEK_END
Indicates a seek from the end of a file. |
| public static final int | SEEK_SET
Indicates a seek from the beginning of a file. |
| Access | Constructor and Description |
|---|---|
| protected | LargeObject(Fastpath
FastPath API for the connection to use fp, long of the Large Object to open oid, int Mode of opening the large object mode, @Nullable BaseConnection the connection to the database used to access this LOB conn, boolean commit the transaction when this LOB will be closed (defined in
LargeObjectManager) commitOnClose)
References Deprecated
Fastpath is deprecated or references (maybe indirectly) at least one deprecated element.
This opens a large object. |
| protected | LargeObject(Fastpath
FastPath API for the connection to use fp, long of the Large Object to open oid, int Mode of opening the large object (defined in LargeObjectManager) mode)
References Deprecated
Fastpath is deprecated or references (maybe indirectly) at least one deprecated element.
This opens a large object. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public LargeObject | |
| public InputStream | |
| public InputStream | Returns: InputStream from this objectmaximum number of bytes the resulting stream will serve limit)Returns an |
| public InputStream | Returns: InputStream from this objectbuffer size for the stream bufferSize, long maximum number of bytes the resulting stream will serve limit)Returns an |
| public long | |
| public int | |
| public OutputStream | |
| public byte[] | Returns: byte[] array containing data readnumber of bytes to read len)Reads some data from the object, and return as a byte[] array. |
| public int | Returns: the number of bytes actually readdestination array buf, int offset within array off, int number of bytes to read len)Reads some data from the object into an existing array. |
| public void | seek(int
position within object pos, int Either SEEK_SET, SEEK_CUR or SEEK_END ref)Sets the current position within the object. |
| public void | |
| public void | seek64(long
position within object pos, int Either SEEK_SET, SEEK_CUR or SEEK_END ref)Sets the current position within the object using 64-bit value (9.3+). |
| public int | Returns: the size of the large objectThis method is inefficient, as the only way to find out the size of the object is to seek to the end, record the current position, then return to the original position. |
| public long | |
| public int | |
| public long | |
| public void | |
| public void | |
| public void | |
| public void | write(byte[]
destination array buf, int offset within array off, int number of bytes to write len)Writes some data from an array to the object. |
| public void | write(ByteStreamWriter
the source of the data to write writer)Writes some data from a given writer to the object. |
| closed | back to summary |
|---|---|
| private boolean closed | |
| commitOnClose | back to summary |
|---|---|
| private final boolean commitOnClose | |
| conn | back to summary |
|---|---|
| private @Nullable BaseConnection conn | |
| EMPTY_BYTE_ARRAY | back to summary |
|---|---|
| private static final byte[] EMPTY_BYTE_ARRAY | |
| fd | back to summary |
|---|---|
| private final int fd | |
| fp | back to summary |
|---|---|
| private final Fastpath fp
References Deprecated
See corresponding docs for further information. | |
| mode | back to summary |
|---|---|
| private final int mode | |
| oid | back to summary |
|---|---|
| private final long oid | |
| os | back to summary |
|---|---|
| private @Nullable BlobOutputStream os | |
| SEEK_CUR | back to summary |
|---|---|
| public static final int SEEK_CUR Indicates a seek from the current position. | |
| SEEK_END | back to summary |
|---|---|
| public static final int SEEK_END Indicates a seek from the end of a file. | |
| SEEK_SET | back to summary |
|---|---|
| public static final int SEEK_SET Indicates a seek from the beginning of a file. | |
| LargeObject | back to summary |
|---|---|
| protected LargeObject(Fastpath fp, long oid, int mode, @Nullable BaseConnection conn, boolean commitOnClose) throws SQLException
References Deprecated
See corresponding docs for further information. This opens a large object. If the object does not exist, then an SQLException is thrown.
| |
| LargeObject | back to summary |
|---|---|
| protected LargeObject(Fastpath fp, long oid, int mode) throws SQLException
References Deprecated
See corresponding docs for further information. This opens a large object. If the object does not exist, then an SQLException is thrown.
| |
| close | back to summary |
|---|---|
| public void close() throws SQLException Implements java. This method closes the object. You must not call methods in this object after this is called.
| |
| copy | back to summary |
|---|---|
| public LargeObject copy() throws SQLException | |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream() throws SQLException Returns an This
| |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream(long limit) throws SQLException Returns an
| |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream(int bufferSize, long limit) throws SQLException Returns an
| |
| getLongOID | back to summary |
|---|---|
public long getLongOID()
| |
| getOID | back to summary |
|---|---|
| public int getOID()
Deprecated As of 8.3, replaced by
| |
| getOutputStream | back to summary |
|---|---|
| public OutputStream getOutputStream() throws SQLException Returns an This OutputStream can then be used in any method that requires an OutputStream.
| |
| read | back to summary |
|---|---|
| public byte[] read(int len) throws SQLException Reads some data from the object, and return as a byte[] array.
| |
| read | back to summary |
|---|---|
| public int read(byte[] buf, int off, int len) throws SQLException Reads some data from the object into an existing array.
| |
| seek | back to summary |
|---|---|
| public void seek(int pos, int ref) throws SQLException Sets the current position within the object. This is similar to the fseek() call in the standard C library. It allows you to have random access to the large object.
| |
| seek | back to summary |
|---|---|
| public void seek(int pos) throws SQLException Sets the current position within the object. This is similar to the fseek() call in the standard C library. It allows you to have random access to the large object.
| |
| seek64 | back to summary |
|---|---|
| public void seek64(long pos, int ref) throws SQLException Sets the current position within the object using 64-bit value (9.3+).
| |
| size | back to summary |
|---|---|
| public int size() throws SQLException This method is inefficient, as the only way to find out the size of the object is to seek to the end, record the current position, then return to the original position. A better method will be found in the future.
| |
| size64 | back to summary |
|---|---|
| public long size64() throws SQLException See #size() for information about efficiency.
| |
| tell | back to summary |
|---|---|
public int tell() throws SQLException
| |
| tell64 | back to summary |
|---|---|
public long tell64() throws SQLException
| |
| truncate | back to summary |
|---|---|
| public void truncate(int len) throws SQLException Truncates the large object to the given length in bytes. If the number of bytes is larger than the current large object length, the large object will be filled with zero bytes. This method does not modify the current file offset.
| |
| truncate64 | back to summary |
|---|---|
| public void truncate64(long len) throws SQLException Truncates the large object to the given length in bytes. If the number of bytes is larger than the current large object length, the large object will be filled with zero bytes. This method does not modify the current file offset.
| |
| write | back to summary |
|---|---|
| public void write(byte[] buf) throws SQLException Writes an array to the object.
| |
| write | back to summary |
|---|---|
| public void write(byte[] buf, int off, int len) throws SQLException Writes some data from an array to the object.
| |
| write | back to summary |
|---|---|
| public void write(ByteStreamWriter writer) throws SQLException Writes some data from a given writer to the object.
| |