© 2002 BEA Systems, Inc.


com.bea.p13n.util.jdbc
Class OracleDatabase

java.lang.Object
  |
  +--com.bea.p13n.util.jdbc.GenericDatabase
        |
        +--com.bea.p13n.util.jdbc.OracleDatabase
Direct Known Subclasses:
OracleThinDatabase, WlsOracleJDriverDatabase, WlsOracleThinDatabase

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 CLOB data.

See Also:
GenericDatabase

Constructor Summary
OracleDatabase(java.sql.Connection connection)
           
 
Method Summary
 java.sql.Clob getClobLocator(java.sql.Connection con, java.lang.String tableName, java.lang.String clobColumnName, java.lang.String whereClause)
           
 java.lang.String getEmptyClobInitializer()
           
 boolean setClob(java.sql.PreparedStatement stmt, int index, java.sql.Clob clob, java.lang.String data)
          Write to a CLOB.
protected  void trimClob(java.sql.Clob clob, long newLength)
          Trim a CLOB to desired size.
 void updateClob(ClobKey key, java.lang.String data)
          Updates a CLOB in the database managed tables for CLOB persistence
 
Methods inherited from class com.bea.p13n.util.jdbc.GenericDatabase
accept, close, close, close, close, close, close, commitConnection, createClobKey, createPreparedStatement, endClob, getApplicationName, getClob, getClobTableName, getConnection, getName, getProperty, insertClob, printSqlWarning, readClob, readFromClob, readFromClob, removeClob, setClob, startClob, writeToClob, writeToClob
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OracleDatabase

public OracleDatabase(java.sql.Connection connection)
Method Detail

updateClob

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

Overrides:
updateClob in class GenericDatabase

getEmptyClobInitializer

public java.lang.String getEmptyClobInitializer()
                                         throws java.sql.SQLException

Overrides:
getEmptyClobInitializer in class GenericDatabase

getClobLocator

public java.sql.Clob getClobLocator(java.sql.Connection con,
                                    java.lang.String tableName,
                                    java.lang.String clobColumnName,
                                    java.lang.String whereClause)
                             throws java.sql.SQLException

Overrides:
getClobLocator in class GenericDatabase

setClob

public boolean setClob(java.sql.PreparedStatement stmt,
                       int index,
                       java.sql.Clob clob,
                       java.lang.String data)
                throws java.sql.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.

Parameters:
stmt - the PreparedStatement
index - the paramater index
clob - the CLOB locator
str - 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.
Throws:
java.sql.SQLException - on an error
Overrides:
setClob in class GenericDatabase

trimClob

protected void trimClob(java.sql.Clob clob,
                        long newLength)
                 throws java.sql.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.


© 2002 BEA Systems, Inc.

Copyright © 2002 BEA Systems, Inc. All Rights Reserved