Oracle JDBC API Reference
11g Release 2 ("11.2.0.3.0")

oracle.sql
Class BFILE

java.lang.Object
  extended by oracle.sql.Datum
      extended by oracle.sql.DatumWithConnection
          extended by oracle.sql.BFILE
All Implemented Interfaces:
java.io.Serializable, oracle.jdbc.internal.OracleDatumWithConnection, OracleBfile

public class BFILE
extends DatumWithConnection
implements oracle.jdbc.internal.OracleBfile

A class for Oracle specific data type BFILE.

See Also:
Serialized Form

Field Summary
static java.lang.String BUILD_DATE
           
static int MAX_CHUNK_SIZE
           
static int MODE_READONLY
           
static int MODE_READWRITE
           
static boolean TRACE
           
 
Method Summary
 java.io.InputStream asciiStreamValue()
          Convert to an ascii stream representation of the datum object
 void close()
          Close a previously opened external LOB.
 void closeFile()
          Close the FILE.
 boolean fileExists()
          Find out if a given BFILE (whose locator) points to a file that actually exists on the server's filesystem.
 java.io.InputStream getBinaryStream()
          Retrieve the entire BFILE as a stream.
 java.io.InputStream getBinaryStream(long pos)
          Read from the external LOB as a stream at the requested position.
 byte[] getBytes(long pos, int length)
          Return a copy of the contents of the BFILE at the requested position.
 int getBytes(long pos, int length, byte[] buf)
          Copy the contents of the BFILE at the requested position to suppied buffer.
 java.lang.String getDirAlias()
          Gets the Bfile's directory alias.
 java.sql.Connection getJavaSqlConnection()
          Oracle extension Return the java.sql.Connection associated with the receiver.
 java.lang.String getName()
          Gets the Bfile's file name.
 boolean isConvertibleTo(java.lang.Class jClass)
          Test whether this data object can be converted to the specified Java data type.
 boolean isFileOpen()
          Find out whether a BFILE was opened with the give BFILE.
 boolean isOpen()
          Check whether the external LOB is opened.
 long length()
          The length of the BFILE in bytes.
 void open()
          Open a external LOB in the readonly mode.
 void open(int mode)
          Open a external LOB in the indicated mode.
 void open(LargeObjectAccessMode mode)
          Public method using enum instead of int
 void openFile()
          Open the FILE.
 long position(BFILE pattern, long start)
          Determine the byte position at which the given pattern
 long position(byte[] pattern, long start)
          Determine the byte position at which the given byte pattern
 long position(OracleBfile pattern, long start)
          Determine the byte position at which the given pattern
 java.lang.Object toJdbc()
          Convert this data object into its default Java object type.
 
Methods inherited from class oracle.sql.DatumWithConnection
assertNotNull, assertNotNull, getConnection, getOracleConnection
 
Methods inherited from class oracle.sql.Datum
bigDecimalValue, booleanValue, byteValue, dateValue, doubleValue, equals, floatValue, getBytes, getLength, getStream, intValue, longValue, setBytes, setShareBytes, shareBytes, stringValue, stringValue, timestampValue, timestampValue, timeValue, timeValue
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface oracle.jdbc.internal.OracleDatumWithConnection
bigDecimalValue, booleanValue, byteValue, dateValue, doubleValue, floatValue, getBytes, getConnection, getInternalConnection, getLength, getOracleConnection, getStream, intValue, longValue, setBytes, setPhysicalConnectionOf, setShareBytes, shareBytes, stringValue, stringValue, timestampValue, timestampValue, timeValue, timeValue
 

Field Detail

MAX_CHUNK_SIZE

public static final int MAX_CHUNK_SIZE
See Also:
Constant Field Values

MODE_READONLY

public static final int MODE_READONLY
See Also:
Constant Field Values

MODE_READWRITE

public static final int MODE_READWRITE
See Also:
Constant Field Values

BUILD_DATE

public static final java.lang.String BUILD_DATE
See Also:
Constant Field Values

TRACE

public static final boolean TRACE
See Also:
Constant Field Values
Method Detail

length

public long length()
            throws java.sql.SQLException
The length of the BFILE in bytes.

Specified by:
length in interface OracleBfile
Returns:
length of the BFILE in bytes
Throws:
java.sql.SQLException

getBytes

public byte[] getBytes(long pos,
                       int length)
                throws java.sql.SQLException
Return a copy of the contents of the BFILE at the requested position.

Specified by:
getBytes in interface OracleBfile
Parameters:
pos - is the first byte of the bfile to be extracted.(1-based)
length - is the number of consecutive bytes to be copied.
Returns:
a byte array containing a portion of the BFILE
Throws:
java.sql.SQLException

getBytes

public int getBytes(long pos,
                    int length,
                    byte[] buf)
             throws java.sql.SQLException
Copy the contents of the BFILE at the requested position to suppied buffer.

Specified by:
getBytes in interface OracleBfile
Parameters:
pos - is the first byte of the bfile to be extracted. (1-based)
length - is the number of consecutive bytes to be copied.
buf - is the buffer to had the extracted bytes.
Returns:
a byte array containing a portion of the BFILE
Throws:
java.sql.SQLException

getBinaryStream

public java.io.InputStream getBinaryStream()
                                    throws java.sql.SQLException
Retrieve the entire BFILE as a stream.

Specified by:
getBinaryStream in interface OracleBfile
Returns:
a stream containing the BFILE data
Throws:
java.sql.SQLException

position

public long position(byte[] pattern,
                     long start)
              throws java.sql.SQLException
Determine the byte position at which the given byte pattern

Specified by:
position in interface OracleBfile
Parameters:
pattern - is the pattern to search for.
start - is the position at which to begin searching. (1-based)
Returns:
the position at which the pattern appears, else -1.
Throws:
java.sql.SQLException

position

public long position(BFILE pattern,
                     long start)
              throws java.sql.SQLException
Determine the byte position at which the given pattern

Parameters:
pattern - is the pattern to search for.
start - is the position at which to begin searching. (1-based)
Returns:
the position at which the pattern appears, else -1.
Throws:
java.sql.SQLException

position

public long position(OracleBfile pattern,
                     long start)
              throws java.sql.SQLException
Determine the byte position at which the given pattern

Specified by:
position in interface OracleBfile
Parameters:
pattern - is the pattern to search for.
start - is the position at which to begin searching. (1-based)
Returns:
the position at which the pattern appears, else -1.
Throws:
java.sql.SQLException

getName

public java.lang.String getName()
                         throws java.sql.SQLException
Gets the Bfile's file name.

Specified by:
getName in interface OracleBfile
Parameters:
bfile - The Bfile for which to get the file name.
Returns:
The file name.
Throws:
java.sql.SQLException

getDirAlias

public java.lang.String getDirAlias()
                             throws java.sql.SQLException
Gets the Bfile's directory alias.

Specified by:
getDirAlias in interface OracleBfile
Parameters:
bfile - The Bfile for which to get the directory alias.
Returns:
The directory alias name.
Throws:
java.sql.SQLException

openFile

public void openFile()
              throws java.sql.SQLException
Open the FILE.

Specified by:
openFile in interface OracleBfile
Parameters:
bfile - The BFILE object to be opened.
Throws:
java.sql.SQLException

isFileOpen

public boolean isFileOpen()
                   throws java.sql.SQLException
Find out whether a BFILE was opened with the give BFILE.

Specified by:
isFileOpen in interface OracleBfile
Parameters:
bfile - The Bfile to be tested.
Returns:
true if the BFILE was opened, false if it was not opened.
Throws:
java.sql.SQLException

fileExists

public boolean fileExists()
                   throws java.sql.SQLException
Find out if a given BFILE (whose locator) points to a file that actually exists on the server's filesystem.

Specified by:
fileExists in interface OracleBfile
Parameters:
bfile - The Bfile to be tested.
Returns:
true if the physical file exists, false if it does not exist.
Throws:
java.sql.SQLException

closeFile

public void closeFile()
               throws java.sql.SQLException
Close the FILE.

Specified by:
closeFile in interface OracleBfile
Parameters:
bfile - The Bfile to be closed.
Throws:
java.sql.SQLException

getBinaryStream

public java.io.InputStream getBinaryStream(long pos)
                                    throws java.sql.SQLException
Read from the external LOB as a stream at the requested position.

Specified by:
getBinaryStream in interface OracleBfile
Parameters:
pos - is the position data to be read.
Returns:
a input stream to read data from the BFILE
Throws:
java.sql.SQLException
Since:
8.2.0

open

public void open()
          throws java.sql.SQLException
Open a external LOB in the readonly mode. It is an error to open the same LOB twice.

Throws:
java.sql.SQLException
Since:
8.2.0

open

public void open(LargeObjectAccessMode mode)
          throws java.sql.SQLException
Public method using enum instead of int

Specified by:
open in interface OracleBfile
Throws:
java.sql.SQLException

open

public void open(int mode)
          throws java.sql.SQLException
Open a external LOB in the indicated mode. Valid modes include MODE_READONLY only. It is an error to open the same LOB twice.

Throws:
java.sql.SQLException
Since:
8.2.0

close

public void close()
           throws java.sql.SQLException
Close a previously opened external LOB.

Specified by:
close in interface OracleBfile
Throws:
java.sql.SQLException
Since:
8.2.0

isOpen

public boolean isOpen()
               throws java.sql.SQLException
Check whether the external LOB is opened.

Specified by:
isOpen in interface OracleBfile
Returns:
true if the LOB is opened.
Throws:
java.sql.SQLException
Since:
8.2.0

toJdbc

public java.lang.Object toJdbc()
                        throws java.sql.SQLException
Convert this data object into its default Java object type.

Specified by:
toJdbc in interface oracle.jdbc.internal.OracleDatumWithConnection
Specified by:
toJdbc in class Datum
Returns:
this object.
Throws:
java.sql.SQLException - if any of the lower layer code throws an exception.

isConvertibleTo

public boolean isConvertibleTo(java.lang.Class jClass)
Test whether this data object can be converted to the specified Java data type.

Specified by:
isConvertibleTo in interface oracle.jdbc.internal.OracleDatumWithConnection
Specified by:
isConvertibleTo in class Datum
Parameters:
jClass - specifies the Java data type to test against.
Returns:
true if this data object is convertible to the specified Java class, and a corresponding xxxValue() method is available; otherwise, a false is returned.

asciiStreamValue

public java.io.InputStream asciiStreamValue()
                                     throws java.sql.SQLException
Convert to an ascii stream representation of the datum object

Specified by:
asciiStreamValue in interface oracle.jdbc.internal.OracleDatumWithConnection
Overrides:
asciiStreamValue in class Datum
Returns:
ascii stream representation of the datum object
Throws:
SQLException, - if no ascii stream representation exists
java.sql.SQLException

getJavaSqlConnection

public java.sql.Connection getJavaSqlConnection()
                                         throws java.sql.SQLException
Description copied from class: DatumWithConnection
Oracle extension Return the java.sql.Connection associated with the receiver. Since 9.0.0 not all Oracle JDBC connection objects are assignment compatible with oracle.jdbc.driver.OracleConnection. If the connection is wrapped, return the outermost wrapper.

Specified by:
getJavaSqlConnection in interface oracle.jdbc.internal.OracleDatumWithConnection
Overrides:
getJavaSqlConnection in class DatumWithConnection
Returns:
the connection
Throws:
java.sql.SQLException - if an error occurs

Oracle JDBC API Reference
11g Release 2 ("11.2.0.3.0")

Copyright © 1998, 2007, Oracle. All rights reserved.