OracleDatabase Class

com.bea.p13n.util.jdbc
OracleDatabase Class

public abstract class OracleDatabase

    extends GenericDatabase

Provides partial implementation of common functionality for Oracle JDBC drivers. Base class for Oracle driver-specific Database instances to support reading/writing of BLOB/CLOB data.

Related Topics

GenericDatabase


Hierarchy
Object
  GenericDatabase
    OracleDatabase
All Implemented Interfaces

Database
Direct Known Subclasses

OracleThinDatabase, WlsOracleJDriverDatabase, WlsOracleThinDatabase

Constructor Summary

OracleDatabase(Connection connection)

 

Method Summary

public Clob
getClobLocator(Connection con, String tableName, String clobColumnName, String whereClause)
public String
getEmptyBlobInitializer()
Returns the String required to initialize a BlobLocator object in an Oracle database.
public String
getEmptyClobInitializer()
public boolean
setClob(PreparedStatement stmt, int index, Clob clob, String data)
Write to a CLOB.
protected void
trimClob(Clob clob, long newLength)
Trim a CLOB to desired size.
public void
updateClob(ClobKey key, String data)
Updates a CLOB in the database managed tables for CLOB persistence
 
Methods from  com.bea.p13n.util.jdbc.GenericDatabase
accept, close, close, close, close, close, close, close, close, close, commitConnection, createPreparedStatement, endBlob, endClob, getApplicationName, getBlob, getBlobLocator, getClob, getClobTableName, getConnection, getName, getProperty, printSqlWarning, readFromClob, readFromClob, setClob, startBlob, startClob, writeToClob, writeToClob
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   
Methods from interface com.bea.p13n.util.jdbc.Database
accept, close, close, close, close, close, close, close, close, close, commitConnection, endBlob, endClob, getApplicationName, getBlob, getBlobLocator, getClob, getClobLocator, getConnection, getEmptyBlobInitializer, getEmptyClobInitializer, getName, readFromClob, setClob, setClob, startBlob, startClob, writeToClob
 

Constructor Detail

OracleDatabase

public OracleDatabase(Connection connection)
 

Method Detail

getClobLocator(Connection, String, String, String) Method

public Clob getClobLocator(Connection con, 
                           String tableName, 
                           String clobColumnName, 
                           String whereClause)
throws SQLException
Overrides
GenericDatabase.getClobLocator(Connection, String, String, String)

Exceptions

SQLException

getEmptyBlobInitializer() Method

public String getEmptyBlobInitializer()
throws SQLException
Returns the String required to initialize a BlobLocator object in an Oracle database. Since you modify the BlobLocator object in the database instead of writing to the column directly, this helps to identify the method used to create one in a PreparedStatement such as INSERT INTO BLOB_TABLE ( ID, BLOBS ) VALUES ( ?, empty_blob() ).

Overrides
GenericDatabase.getEmptyBlobInitializer()

Returns

String method used to create a BlobLocator in an Oracle database.

Exceptions

SQLException
on an error.

getEmptyClobInitializer() Method

public String getEmptyClobInitializer()
throws SQLException
Overrides
GenericDatabase.getEmptyClobInitializer()

Exceptions

SQLException

setClob(PreparedStatement, int, Clob, String) Method

public boolean setClob(PreparedStatement stmt, 
                       int index, 
                       Clob clob, 
                       String data)
throws SQLException
Write to a CLOB. Write the input stream containing the ASCII data associated with the passed String to the CLOB's output stream. Streams support for updating CLOB columns is not addressed by JDBC 2.0 so this method uses an extension implemented in the delegate. This will always return false, since the Clob is written directly to the database.

Overrides
GenericDatabase.setClob(PreparedStatement, int, Clob, String)

Parameters

stmt
the PreparedStatement
index
the paramater index
clob
the CLOB locator
data
the string value

Returns

boolean executeRequired. If false then a delegate was used to directly set the CLOB in the database without using the PreparedStatement. If true then no delegate was used, or the delegate set the Clob value on the statement and the PreparedStatement must be executed to update the database.

Exceptions

SQLException
on an error

trimClob(Clob, long) Method

protected void trimClob(Clob clob, 
                        long newLength)
throws SQLException
Trim a CLOB to desired size. This method does not commit the connection. In normal use, you will call this method with a connection that has auto-commit disabled. After you have called this method with such a connection you can then commit it (if you are finished with the CLOB).

If the newLength is greater than or equal to the current CLOB length (determined from Clob.length()) then nothing is done.

This trim is required because Oracle has some strange behavior for CLOB UPDATEs:

If you use UPDATE to put a small CLOB into a field that contains a larger CLOB, then the CLOB size remains unchanged. In other words, the new small CLOB data overlaps the large CLOB data and the end of the CLOB consists of the old data from the end of the large CLOB.

Exceptions

SQLException

updateClob(ClobKey, String) Method

public void updateClob(ClobKey key, 
                       String data)
throws SQLException
Updates a CLOB in the database managed tables for CLOB persistence

Exceptions

SQLException