All Packages Class Hierarchy This Package Previous Next Index
Class postgresql.largeobject.LargeObject
java.lang.Object
|
+----postgresql.largeobject.LargeObject
- public class LargeObject
- extends Object
This class implements the large object interface to postgresql.
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, 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 postgresql.largeobject.LargeObjectManager on how to gain access
to a Large Object, or how to create one.
- See Also:
- LargeObjectManager, getAsciiStream, getBinaryStream, getUnicodeStream, setAsciiStream, setBinaryStream, setUnicodeStream, getAsciiStream, getBinaryStream, getUnicodeStream, setAsciiStream, setBinaryStream, setUnicodeStream
-
SEEK_CUR
- Indicates a seek from the current position
-
SEEK_END
- Indicates a seek from the end of a file
-
SEEK_SET
- Indicates a seek from the begining of a file
-
close()
- This method closes the object.
-
getInputStream()
- Returns an InputStream from this object.
-
getOID()
-
-
getOutputStream()
- Returns an OutputStream to this object
This OutputStream can then be used in any method that requires an
OutputStream.
-
read(byte[], int, int)
- Reads some data from the object into an existing array
-
read(int)
- Reads some data from the object, and return as a byte[] array
-
seek(int)
- Sets the current position within the object.
-
seek(int, int)
- Sets the current position within the object.
-
size()
- 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.
-
tell()
-
-
write(byte[])
- Writes an array to the object
-
write(byte[], int, int)
- Writes some data from an array to the object
SEEK_SET
public static final int SEEK_SET
- Indicates a seek from the begining of a file
SEEK_CUR
public static final int SEEK_CUR
- Indicates a seek from the current position
SEEK_END
public static final int SEEK_END
- Indicates a seek from the end of a file
getOID
public int getOID()
- Returns:
- the OID of this LargeObject
close
public void close() throws SQLException
- This method closes the object. You must not call methods in this
object after this is called.
- Throws: SQLException
- if a database-access error occurs.
read
public byte[] read(int len) throws SQLException
- Reads some data from the object, and return as a byte[] array
- Parameters:
- len - number of bytes to read
- Returns:
- byte[] array containing data read
- Throws: SQLException
- if a database-access error occurs.
read
public void read(byte buf[],
int off,
int len) throws SQLException
- Reads some data from the object into an existing array
- Parameters:
- buf - destination array
- off - offset within array
- len - number of bytes to read
- Throws: SQLException
- if a database-access error occurs.
write
public void write(byte buf[]) throws SQLException
- Writes an array to the object
- Parameters:
- buf - array to write
- Throws: SQLException
- if a database-access error occurs.
write
public void write(byte buf[],
int off,
int len) throws SQLException
- Writes some data from an array to the object
- Parameters:
- buf - destination array
- off - offset within array
- len - number of bytes to write
- Throws: SQLException
- if a database-access error occurs.
seek
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.
- Parameters:
- pos - position within object
- ref - Either SEEK_SET, SEEK_CUR or SEEK_END
- Throws: SQLException
- if a database-access error occurs.
seek
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.
- Parameters:
- pos - position within object from begining
- Throws: SQLException
- if a database-access error occurs.
tell
public int tell() throws SQLException
- Returns:
- the current position within the object
- Throws: SQLException
- if a database-access error occurs.
size
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.
- Returns:
- the size of the large object
- Throws: SQLException
- if a database-access error occurs.
getInputStream
public InputStream getInputStream() throws SQLException
- Returns an InputStream from this object.
This InputStream can then be used in any method that requires an
InputStream.
- Throws: SQLException
- if a database-access error occurs.
getOutputStream
public OutputStream getOutputStream() throws SQLException
- Returns an OutputStream to this object
This OutputStream can then be used in any method that requires an
OutputStream.
- Throws: SQLException
- if a database-access error occurs.
All Packages Class Hierarchy This Package Previous Next Index