クラス LargeObject
- すべての実装されたインタフェース:
AutoCloseable
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.
- 関連項目:
-
LargeObjectManager
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)
-
フィールドの概要
フィールド -
コンストラクタの概要
コンストラクタ修飾子コンストラクタ説明protected
LargeObject
(Fastpath fp, long oid, int mode) This opens a large object.protected
LargeObject
(Fastpath fp, long oid, int mode, @Nullable BaseConnection conn, boolean commitOnClose) This opens a large object. -
メソッドの概要
修飾子とタイプメソッド説明void
close()
This method closes the object.copy()
Returns anInputStream
from this object.getInputStream
(int bufferSize, long limit) Returns anInputStream
from this object, that will limit the amount of data that is visible.getInputStream
(long limit) Returns anInputStream
from this object, that will limit the amount of data that is visible.long
int
getOID()
推奨されていません。Returns anOutputStream
to this object.int
read
(byte[] buf, int off, int len) Reads some data from the object into an existing array.byte[]
read
(int len) Reads some data from the object, and return as a byte[] array.void
seek
(int pos) Sets the current position within the object.void
seek
(int pos, int ref) Sets the current position within the object.void
seek64
(long pos, int ref) Sets the current position within the object using 64-bit value (9.3+).int
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.long
size64()
See #size() for information about efficiency.int
tell()
long
tell64()
void
truncate
(int len) Truncates the large object to the given length in bytes.void
truncate64
(long len) Truncates the large object to the given length in bytes.void
write
(byte[] buf) Writes an array to the object.void
write
(byte[] buf, int off, int len) Writes some data from an array to the object.void
write
(ByteStreamWriter writer) Writes some data from a given writer to the object.
-
フィールド詳細
-
SEEK_SET
public static final int SEEK_SETIndicates a seek from the beginning of a file.- 関連項目:
-
SEEK_CUR
public static final int SEEK_CURIndicates a seek from the current position.- 関連項目:
-
SEEK_END
public static final int SEEK_ENDIndicates a seek from the end of a file.- 関連項目:
-
-
コンストラクタの詳細
-
LargeObject
protected LargeObject(Fastpath fp, long oid, int mode, @Nullable BaseConnection conn, boolean commitOnClose) throws SQLException This opens a large object.
If the object does not exist, then an SQLException is thrown.
- パラメータ:
fp
- FastPath API for the connection to useoid
- of the Large Object to openmode
- Mode of opening the large objectconn
- the connection to the database used to access this LOBcommitOnClose
- commit the transaction when this LOB will be closed (defined in LargeObjectManager)- 例外:
SQLException
- if a database-access error occurs.- 関連項目:
-
LargeObject
This opens a large object.
If the object does not exist, then an SQLException is thrown.
- パラメータ:
fp
- FastPath API for the connection to useoid
- of the Large Object to openmode
- Mode of opening the large object (defined in LargeObjectManager)- 例外:
SQLException
- if a database-access error occurs.- 関連項目:
-
-
メソッドの詳細
-
copy
- 例外:
SQLException
-
getOID
推奨されていません。As of 8.3, replaced bygetLongOID()
- 戻り値:
- the OID of this LargeObject
-
getLongOID
public long getLongOID()- 戻り値:
- the OID of this LargeObject
-
close
This method closes the object. You must not call methods in this object after this is called.- 定義:
close
インタフェース内AutoCloseable
- 例外:
SQLException
- if a database-access error occurs.
-
read
Reads some data from the object, and return as a byte[] array.- パラメータ:
len
- number of bytes to read- 戻り値:
- byte[] array containing data read
- 例外:
SQLException
- if a database-access error occurs.
-
read
Reads some data from the object into an existing array.- パラメータ:
buf
- destination arrayoff
- offset within arraylen
- number of bytes to read- 戻り値:
- the number of bytes actually read
- 例外:
SQLException
- if a database-access error occurs.
-
write
Writes an array to the object.- パラメータ:
buf
- array to write- 例外:
SQLException
- if a database-access error occurs.
-
write
Writes some data from an array to the object.- パラメータ:
buf
- destination arrayoff
- offset within arraylen
- number of bytes to write- 例外:
SQLException
- if a database-access error occurs.
-
write
Writes some data from a given writer to the object.- パラメータ:
writer
- the source of the data to write- 例外:
SQLException
- if a database-access error occurs.
-
seek
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.
- パラメータ:
pos
- position within objectref
- Either SEEK_SET, SEEK_CUR or SEEK_END- 例外:
SQLException
- if a database-access error occurs.
-
seek64
Sets the current position within the object using 64-bit value (9.3+).- パラメータ:
pos
- position within objectref
- Either SEEK_SET, SEEK_CUR or SEEK_END- 例外:
SQLException
- if a database-access error occurs.
-
seek
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.
- パラメータ:
pos
- position within object from beginning- 例外:
SQLException
- if a database-access error occurs.
-
tell
- 戻り値:
- the current position within the object
- 例外:
SQLException
- if a database-access error occurs.
-
tell64
- 戻り値:
- the current position within the object
- 例外:
SQLException
- if a database-access error occurs.
-
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.
A better method will be found in the future.
- 戻り値:
- the size of the large object
- 例外:
SQLException
- if a database-access error occurs.
-
size64
See #size() for information about efficiency.- 戻り値:
- the size of the large object
- 例外:
SQLException
- if a database-access error occurs.
-
truncate
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.- パラメータ:
len
- given length in bytes- 例外:
SQLException
- if something goes wrong
-
truncate64
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.- パラメータ:
len
- given length in bytes- 例外:
SQLException
- if something goes wrong
-
getInputStream
Returns an
InputStream
from this object.This
InputStream
can then be used in any method that requires an InputStream.- 戻り値:
InputStream
from this object- 例外:
SQLException
- if a database-access error occurs.
-
getInputStream
Returns anInputStream
from this object, that will limit the amount of data that is visible.- パラメータ:
limit
- maximum number of bytes the resulting stream will serve- 戻り値:
InputStream
from this object- 例外:
SQLException
- if a database-access error occurs.
-
getInputStream
Returns anInputStream
from this object, that will limit the amount of data that is visible. Added mostly for testing- パラメータ:
bufferSize
- buffer size for the streamlimit
- maximum number of bytes the resulting stream will serve- 戻り値:
InputStream
from this object- 例外:
SQLException
- if a database-access error occurs.
-
getOutputStream
Returns an
OutputStream
to this object.This OutputStream can then be used in any method that requires an OutputStream.
- 戻り値:
OutputStream
from this object- 例外:
SQLException
- if a database-access error occurs.
-
getLongOID()