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

Variable Index

 o SEEK_CUR
Indicates a seek from the current position
 o SEEK_END
Indicates a seek from the end of a file
 o SEEK_SET
Indicates a seek from the begining of a file

Method Index

 o close()
This method closes the object.
 o getInputStream()
Returns an InputStream from this object.
 o getOID()
 o getOutputStream()
Returns an OutputStream to this object

This OutputStream can then be used in any method that requires an OutputStream.

 o read(byte[], int, int)
Reads some data from the object into an existing array
 o read(int)
Reads some data from the object, and return as a byte[] array
 o seek(int)
Sets the current position within the object.
 o seek(int, int)
Sets the current position within the object.
 o 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.
 o tell()
 o write(byte[])
Writes an array to the object
 o write(byte[], int, int)
Writes some data from an array to the object

Variables

 o SEEK_SET
 public static final int SEEK_SET
Indicates a seek from the begining of a file

 o SEEK_CUR
 public static final int SEEK_CUR
Indicates a seek from the current position

 o SEEK_END
 public static final int SEEK_END
Indicates a seek from the end of a file

Methods

 o getOID
 public int getOID()
Returns:
the OID of this LargeObject
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o tell
 public int tell() throws SQLException
Returns:
the current position within the object
Throws: SQLException
if a database-access error occurs.
 o 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.
 o 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.
 o 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