© 2003 BEA Systems, Inc.

com.bea.p13n.util.jdbc
Class SetStringDatabase

java.lang.Object
  |
  +--com.bea.p13n.util.jdbc.GenericDatabase
        |
        +--com.bea.p13n.util.jdbc.SetStringDatabase
All Implemented Interfaces:
Database

public class SetStringDatabase
extends GenericDatabase


Constructor Summary
SetStringDatabase(Connection connection)
           
 
Method Summary
 boolean commitConnection(Connection connection)
           
 String getClob(ResultSet rs, int index)
          Get the value of a CLOB column as a string.
 String getName()
          The name of this GenericDatabase instance.
 boolean setClob(PreparedStatement stmt, int index, Clob clob, String str)
          If there is a delegate, this method uses JdbcHelperDelegate.writeClobData() If this is done, then the PreparedStatement does not need to be used and the return value, executeRequired, is false.
 void setClob(PreparedStatement stmt, int index, String str)
          Set the value of a CLOB column with a string.
 
Methods inherited from class com.bea.p13n.util.jdbc.GenericDatabase
accept, close, close, close, close, close, close, close, close, close, createPreparedStatement, endBlob, endClob, getApplicationName, getBlob, getBlobLocator, getClobLocator, getClobTableName, getConnection, getEmptyBlobInitializer, getEmptyClobInitializer, getProperty, printSqlWarning, readFromClob, readFromClob, startBlob, startClob, writeToClob, writeToClob
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SetStringDatabase

public SetStringDatabase(Connection connection)
Method Detail

getClob

public String getClob(ResultSet rs,
                      int index)
               throws SQLException
Description copied from interface: Database
Get the value of a CLOB column as a string.

This method will only return the value of the CLOB in the current row of the ResultSet. This method does not increment the ResultSet cursor. You must use ResultSet.next() to increment the cursor before calling this method. This allows the method to be used to process multi-row ResultSets.

If no JdbcHelperDelegate is specified in the console (configured via JdbcHelperMBean) then this method will return a string obtained using the default method that was used before a delegate model was implemented for this class. That method uses Clob.getCharacterStream() to construct a BufferedReader that is read in with the readLine() method.

Specified by:
getClob in interface Database
Overrides:
getClob in class GenericDatabase
Parameters:
rs - the result set.
index - the column index in the result set.
Returns:
the column as a string.
Throws:
SQLException - thrown on an error.

setClob

public void setClob(PreparedStatement stmt,
                    int index,
                    String str)
             throws SQLException
Description copied from interface: Database
Set the value of a CLOB column with a string.

Specified by:
setClob in interface Database
Overrides:
setClob in class GenericDatabase
Parameters:
stmt - the prepared statement.
index - the column index.
str - the CLOB string.
Throws:
SQLException - thrown on an error.

setClob

public boolean setClob(PreparedStatement stmt,
                       int index,
                       Clob clob,
                       String str)
                throws SQLException
Description copied from interface: Database
If there is a delegate, this method uses JdbcHelperDelegate.writeClobData() If this is done, then the PreparedStatement does not need to be used and the return value, executeRequired, is false. The CLOB should be first located with getClobLocator() If there is no delegate, then this method ignores the Clob argument and sets the value of the String into the CLOB placeholder in the PreparedStatement with setClob(PreparedStatement stmt, int index, String str) and returns executeRequired = true.

WARNING: if using a delegate to stream data to a CLOB, then you should have used Connection.setAutoCommit(false) before calling the CLOB locator method that provided the Clob you are using in this method call. This will make the CLOB available across multiple SQL statements.

Specified by:
setClob in interface Database
Overrides:
setClob in class GenericDatabase
Parameters:
stmt - the prepared statement.
index - the column index.
clob - the CLOB locator (ignored if no delegate).
str - the String to be set in the CLOB (if delegate) or in the PreparedStatement (if no delegate)
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:
SQLException - thrown on an error.

commitConnection

public boolean commitConnection(Connection connection)
                         throws SQLException
Specified by:
commitConnection in interface Database
Overrides:
commitConnection in class GenericDatabase
SQLException

getName

public String getName()
Description copied from class: GenericDatabase
The name of this GenericDatabase instance.

Specified by:
getName in interface Database
Overrides:
getName in class GenericDatabase
Returns:
the name of the database

© 2003 BEA Systems, Inc.

Copyright © 2003 BEA Systems, Inc. All Rights Reserved