Top Description Fields Constructors Methods
org.postgresql.largeobject

public Class LargeObjectManager

extends Object
Class Inheritance
Annotations
@SuppressWarnings:deprecation
Imports
org.postgresql.core.BaseConnection, org.postgresql.fastpath.Fastpath, .FastpathArg, org.postgresql.util.GT, .PSQLException, .PSQLState, java.sql.ResultSet, .SQLException, .Statement, java.util.logging.Level

This class implements the large object interface to org.postgresql.

It provides methods that allow client code to create, open and delete large objects from the database. When opening an object, an instance of org.postgresql.largeobject.LargeObject is returned, and its methods then allow access to the object.

This class can only be created by BaseConnection

To get access to this class, use the following segment of code:

import org.postgresql.largeobject.*;

Connection  conn;
LargeObjectManager lobj;

... code that opens a connection ...

lobj = ((org.postgresql.PGConnection)myconn).getLargeObjectAPI();

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.LargeObject on how to manipulate the contents of a Large Object.

See Also
java.sql.ResultSet#getAsciiStream, java.sql.ResultSet#getBinaryStream, java.sql.ResultSet#getUnicodeStream, java.sql.PreparedStatement#setAsciiStream, java.sql.PreparedStatement#setBinaryStream, java.sql.PreparedStatement#setUnicodeStream

Field Summary

Modifier and TypeField and Description
private BaseConnection
private Fastpath
fp

References Deprecated Fastpath is deprecated or references (maybe indirectly) at least one deprecated element.
public static final int
READ

This mode indicates we want to read an object.

public static final int
READWRITE

This mode is the default.

public static final int
WRITE

This mode indicates we want to write to an object.

Constructor Summary

AccessConstructor and Description
public
LargeObjectManager(BaseConnection
connection
conn
)

Constructs the LargeObject API.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

oid of new object
create
()
Deprecated As of 8.3, replaced by createLO()

This creates a large object, returning its OID.

public int

Returns:

oid of new object
create
(int
a bitmask describing different attributes of the new object
mode
)
Deprecated As of 8.3, replaced by createLO(int)

This creates a large object, returning its OID.

public long

Returns:

oid of new object
createLO
()

This creates a large object, returning its OID.

public long

Returns:

oid of new object
createLO
(int
a bitmask describing different attributes of the new object
mode
)

This creates a large object, returning its OID.

public void
delete(long
describing object to delete
oid
)

This deletes a large object.

public void
delete(int
describing object to delete
oid
)
Deprecated As of 8.3, replaced by delete(long)

This deletes a large object.

public LargeObject

Returns:

LargeObject instance providing access to the object
open
(int
of large object
oid
)
Deprecated As of 8.3, replaced by open(long)

This opens an existing large object, based on its OID.

public LargeObject

Returns:

LargeObject instance providing access to the object
open
(int
of large object
oid
,
boolean
commit the transaction when this LOB will be closed
commitOnClose
)

This opens an existing large object, same as previous method, but commits the transaction on close if asked.

public LargeObject

Returns:

LargeObject instance providing access to the object
open
(long
of large object
oid
)

This opens an existing large object, based on its OID.

public LargeObject

Returns:

LargeObject instance providing access to the object
open
(long
of large object
oid
,
boolean
commit the transaction when this LOB will be closed
commitOnClose
)

This opens an existing large object, same as previous method, but commits the transaction on close if asked.

public LargeObject

Returns:

LargeObject instance providing access to the object
open
(int
of large object
oid
,
int
mode of open
mode
)
Deprecated As of 8.3, replaced by open(long, int)

This opens an existing large object, based on its OID.

public LargeObject

Returns:

LargeObject instance providing access to the object
open
(int
of large object
oid
,
int
mode of open
mode
,
boolean
commit the transaction when this LOB will be closed
commitOnClose
)

This opens an existing large object, same as previous method, but commits the transaction on close if asked.

public LargeObject

Returns:

LargeObject instance providing access to the object
open
(long
of large object
oid
,
int
mode of open
mode
)

This opens an existing large object, based on its OID.

public LargeObject

Returns:

LargeObject instance providing access to the object
open
(long
of large object
oid
,
int
mode of open
mode
,
boolean
commit the transaction when this LOB will be closed
commitOnClose
)

This opens an existing large object, based on its OID.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connback to summary
private BaseConnection conn
fpback to summary
private Fastpath fp

References Deprecated

Fastpath is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

READback to summary
public static final int READ

This mode indicates we want to read an object.

READWRITEback to summary
public static final int READWRITE

This mode is the default. It indicates we want read and write access to a large object.

WRITEback to summary
public static final int WRITE

This mode indicates we want to write to an object.

Constructor Detail

LargeObjectManagerback to summary
public LargeObjectManager(BaseConnection conn) throws SQLException

Constructs the LargeObject API.

Important Notice
This method should only be called by BaseConnection

There should only be one LargeObjectManager per Connection. The BaseConnection class keeps track of the various extension API's and it's advised you use those to gain access, and not going direct.

Parameters
conn:BaseConnection

connection

Exceptions
SQLException:
if something wrong happens

Method Detail

createback to summary
public int create() throws SQLException

Deprecated

As of 8.3, replaced by createLO()

This creates a large object, returning its OID.

It defaults to READWRITE for the new object's attributes.

Returns:int

oid of new object

Annotations
@Deprecated
Exceptions
SQLException:
on error
createback to summary
public int create(int mode) throws SQLException

Deprecated

As of 8.3, replaced by createLO(int)

This creates a large object, returning its OID.

Parameters
mode:int

a bitmask describing different attributes of the new object

Returns:int

oid of new object

Annotations
@Deprecated
Exceptions
SQLException:
on error
createLOback to summary
public long createLO() throws SQLException

This creates a large object, returning its OID.

It defaults to READWRITE for the new object's attributes.

Returns:long

oid of new object

Exceptions
SQLException:
if something wrong happens
createLOback to summary
public long createLO(int mode) throws SQLException

This creates a large object, returning its OID.

Parameters
mode:int

a bitmask describing different attributes of the new object

Returns:long

oid of new object

Exceptions
SQLException:
on error
deleteback to summary
public void delete(long oid) throws SQLException

This deletes a large object.

Parameters
oid:long

describing object to delete

Exceptions
SQLException:
on error
deleteback to summary
public void delete(int oid) throws SQLException

Deprecated

As of 8.3, replaced by delete(long)

This deletes a large object.

Parameters
oid:int

describing object to delete

Annotations
@Deprecated
Exceptions
SQLException:
on error
openback to summary
public LargeObject open(int oid) throws SQLException

Deprecated

As of 8.3, replaced by open(long)

This opens an existing large object, based on its OID. This method assumes that READ and WRITE access is required (the default).

Parameters
oid:int

of large object

Returns:LargeObject

LargeObject instance providing access to the object

Annotations
@Deprecated
Exceptions
SQLException:
on error
openback to summary
public LargeObject open(int oid, boolean commitOnClose) throws SQLException

This opens an existing large object, same as previous method, but commits the transaction on close if asked. This is useful when the LOB is returned to a caller which won't take care of transactions by itself.

Parameters
oid:int

of large object

commitOnClose:boolean

commit the transaction when this LOB will be closed

Returns:LargeObject

LargeObject instance providing access to the object

Exceptions
SQLException:
on error
openback to summary
public LargeObject open(long oid) throws SQLException

This opens an existing large object, based on its OID. This method assumes that READ and WRITE access is required (the default).

Parameters
oid:long

of large object

Returns:LargeObject

LargeObject instance providing access to the object

Exceptions
SQLException:
on error
openback to summary
public LargeObject open(long oid, boolean commitOnClose) throws SQLException

This opens an existing large object, same as previous method, but commits the transaction on close if asked.

Parameters
oid:long

of large object

commitOnClose:boolean

commit the transaction when this LOB will be closed

Returns:LargeObject

LargeObject instance providing access to the object

Exceptions
SQLException:
on error
openback to summary
public LargeObject open(int oid, int mode) throws SQLException

Deprecated

As of 8.3, replaced by open(long, int)

This opens an existing large object, based on its OID.

Parameters
oid:int

of large object

mode:int

mode of open

Returns:LargeObject

LargeObject instance providing access to the object

Annotations
@Deprecated
Exceptions
SQLException:
on error
openback to summary
public LargeObject open(int oid, int mode, boolean commitOnClose) throws SQLException

This opens an existing large object, same as previous method, but commits the transaction on close if asked.

Parameters
oid:int

of large object

mode:int

mode of open

commitOnClose:boolean

commit the transaction when this LOB will be closed

Returns:LargeObject

LargeObject instance providing access to the object

Exceptions
SQLException:
on error
openback to summary
public LargeObject open(long oid, int mode) throws SQLException

This opens an existing large object, based on its OID.

Parameters
oid:long

of large object

mode:int

mode of open

Returns:LargeObject

LargeObject instance providing access to the object

Exceptions
SQLException:
on error
openback to summary
public LargeObject open(long oid, int mode, boolean commitOnClose) throws SQLException

This opens an existing large object, based on its OID.

Parameters
oid:long

of large object

mode:int

mode of open

commitOnClose:boolean

commit the transaction when this LOB will be closed

Returns:LargeObject

LargeObject instance providing access to the object

Exceptions
SQLException:
on error