public class LargeObjectManager
extends java.lang.Object
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 org.postgresql.Connection
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.
ResultSet.getAsciiStream(int)
,
ResultSet.getBinaryStream(int)
,
ResultSet.getUnicodeStream(int)
,
PreparedStatement.setAsciiStream(int, java.io.InputStream, int)
,
PreparedStatement.setBinaryStream(int, java.io.InputStream, int)
,
PreparedStatement.setUnicodeStream(int, java.io.InputStream, int)
Modifier and Type | Field and Description |
---|---|
static int |
READ
This mode indicates we want to read an object
|
static int |
READWRITE
This mode is the default.
|
static int |
WRITE
This mode indicates we want to write to an object
|
Constructor and Description |
---|
LargeObjectManager(org.postgresql.core.BaseConnection conn)
Constructs the LargeObject API.
|
Modifier and Type | Method and Description |
---|---|
int |
create()
Deprecated.
As of 8.3, replaced by
createLO() |
int |
create(int mode)
Deprecated.
As of 8.3, replaced by
createLO(int) |
long |
createLO()
This creates a large object, returning its OID.
|
long |
createLO(int mode)
This creates a large object, returning its OID
|
void |
delete(int oid)
Deprecated.
As of 8.3, replaced by
delete(long) |
void |
delete(long oid)
This deletes a large object.
|
LargeObject |
open(int oid)
Deprecated.
As of 8.3, replaced by
open(long) |
LargeObject |
open(int oid,
boolean commitOnClose)
This opens an existing large object, same as previous method,
but commits the transaction on close if asked.
|
LargeObject |
open(int oid,
int mode)
Deprecated.
As of 8.3, replaced by
open(long, int) |
LargeObject |
open(int oid,
int mode,
boolean commitOnClose)
This opens an existing large object, same as previous method,
but commits the transaction on close if asked
|
LargeObject |
open(long oid)
This opens an existing large object, based on its OID.
|
LargeObject |
open(long oid,
boolean commitOnClose)
This opens an existing large object, same as previous method,
but commits the transaction on close if asked
|
LargeObject |
open(long oid,
int mode)
This opens an existing large object, based on its OID
|
LargeObject |
open(long oid,
int mode,
boolean commitOnClose)
This opens an existing large object, based on its OID
|
void |
unlink(int oid)
Deprecated.
As of 8.3, replaced by
unlink(long) |
void |
unlink(long oid)
This deletes a large object.
|
public static final int WRITE
public static final int READ
public static final int READWRITE
public LargeObjectManager(org.postgresql.core.BaseConnection conn) throws java.sql.SQLException
Important Notice
This method should only be called by org.postgresql.Connection
There should only be one LargeObjectManager per Connection. The org.postgresql.Connection class keeps track of the various extension API's and it's advised you use those to gain access, and not going direct.
java.sql.SQLException
public LargeObject open(int oid) throws java.sql.SQLException
open(long)
oid
- of large objectjava.sql.SQLException
- on errorpublic LargeObject open(int oid, boolean commitOnClose) throws java.sql.SQLException
oid
- of large objectcommitOnClose
- commit the transaction when this LOB will be closedjava.sql.SQLException
- on errorpublic LargeObject open(long oid) throws java.sql.SQLException
oid
- of large objectjava.sql.SQLException
- on errorpublic LargeObject open(long oid, boolean commitOnClose) throws java.sql.SQLException
oid
- of large objectcommitOnClose
- commit the transaction when this LOB will be closedjava.sql.SQLException
- on errorpublic LargeObject open(int oid, int mode) throws java.sql.SQLException
open(long, int)
oid
- of large objectmode
- mode of openjava.sql.SQLException
- on errorpublic LargeObject open(int oid, int mode, boolean commitOnClose) throws java.sql.SQLException
oid
- of large objectmode
- mode of opencommitOnClose
- commit the transaction when this LOB will be closedjava.sql.SQLException
- on errorpublic LargeObject open(long oid, int mode) throws java.sql.SQLException
oid
- of large objectmode
- mode of openjava.sql.SQLException
- on errorpublic LargeObject open(long oid, int mode, boolean commitOnClose) throws java.sql.SQLException
oid
- of large objectmode
- mode of opencommitOnClose
- commit the transaction when this LOB will be closedjava.sql.SQLException
- on errorpublic int create() throws java.sql.SQLException
createLO()
It defaults to READWRITE for the new object's attributes.
java.sql.SQLException
- on errorpublic long createLO() throws java.sql.SQLException
It defaults to READWRITE for the new object's attributes.
java.sql.SQLException
public long createLO(int mode) throws java.sql.SQLException
mode
- a bitmask describing different attributes of the new objectjava.sql.SQLException
- on errorpublic int create(int mode) throws java.sql.SQLException
createLO(int)
mode
- a bitmask describing different attributes of the new objectjava.sql.SQLException
- on errorpublic void delete(long oid) throws java.sql.SQLException
oid
- describing object to deletejava.sql.SQLException
- on errorpublic void unlink(int oid) throws java.sql.SQLException
unlink(long)
It is identical to the delete method, and is supplied as the C API uses unlink.
oid
- describing object to deletejava.sql.SQLException
- on errorpublic void unlink(long oid) throws java.sql.SQLException
It is identical to the delete method, and is supplied as the C API uses unlink.
oid
- describing object to deletejava.sql.SQLException
- on errorpublic void delete(int oid) throws java.sql.SQLException
delete(long)
oid
- describing object to deletejava.sql.SQLException
- on error