© 2002 BEA Systems, Inc.


com.bea.p13n.util.jdbc
Class GenericDatabase

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

public class GenericDatabase
extends java.lang.Object
implements Database

Concrete implementation of the Database interface. This implementation is designed to be used with database drivers that support Statement.setCharacterStream() and Clob.getCharacterStream to write/read CLOBs.

The setClob and getClob methods in this class should be overidden if a driver does not support the above methods to manipulate CLOBs.

See Also:
Database

Constructor Summary
GenericDatabase(java.sql.Connection connection)
           
 
Method Summary
 boolean accept(java.sql.Connection connection)
           
 void close()
          Close the Connection associated with this Database
 void close(java.io.Reader reader)
           
 void close(java.sql.ResultSet rs)
          Close a result set, ignoring any errors.
 void close(java.sql.ResultSet rs, java.sql.Statement stmt)
          Close a statement and resultset, ignoring errors.
 void close(java.sql.Statement stmt)
          Close a statement, ignoring any errors.
 void close(java.io.Writer writer)
           
 boolean commitConnection(java.sql.Connection connection)
           
 ClobKey createClobKey(java.lang.String namespace, java.lang.String identifier)
          Creates an instance of ClobKey for the given namespace and identifier.
protected  java.sql.PreparedStatement createPreparedStatement(java.lang.String key)
           
 void endClob()
          Call Connection.commit
 java.lang.String getApplicationName()
          Get the name of the current WebLogic J2EE application or return null if not running within a WebLogic J2EE context.
 java.lang.String getClob(java.sql.ResultSet rs, int index)
           
 java.sql.Clob getClobLocator(java.sql.Connection con, java.lang.String tableName, java.lang.String clobColumnName, java.lang.String whereClause)
           
 java.lang.String getClobTableName()
           
 java.sql.Connection getConnection()
           
 java.lang.String getEmptyClobInitializer()
           
 java.lang.String getName()
           
protected  java.lang.String getProperty(java.lang.String propertyName)
           
 void insertClob(ClobKey key, java.lang.String data)
          Inserts a CLOB into the database managed tables for CLOB persistence
protected  void printSqlWarning(java.sql.SQLWarning warning)
           
 java.lang.String readClob(ClobKey key)
          Reads a CLOB into the database managed tables for CLOB persistence
 java.lang.String readFromClob(java.sql.Clob clob)
          Reads the contents of a Clob and returns as a String.
 java.lang.String readFromClob(java.sql.ResultSet resultSet, int index)
           
 void removeClob(ClobKey key)
          Removes a CLOB from the database managed tables for CLOB persistence
 boolean setClob(java.sql.PreparedStatement stmt, int index, java.sql.Clob clob, java.lang.String str)
           
 void setClob(java.sql.PreparedStatement stmt, int index, java.lang.String str)
           
 void startClob()
          setAutoCommit( false ) on the Connection
 void updateClob(ClobKey key, java.lang.String data)
          Updates a CLOB in the database managed tables for CLOB persistence
 void writeToClob(java.sql.Clob clob, java.lang.String data)
          Writes the data from the String into the Clob.
 java.io.Reader writeToClob(java.sql.PreparedStatement statement, int index, java.lang.String data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericDatabase

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

accept

public boolean accept(java.sql.Connection connection)
Specified by:
accept in interface Database

Returns:
true if this Database can accept a connection URL of the supplied form.

getConnection

public java.sql.Connection getConnection()
Specified by:
getConnection in interface Database


close

public void close()
Close the Connection associated with this Database
Specified by:
close in interface Database


close

public void close(java.sql.Statement stmt)
Close a statement, ignoring any errors.
Specified by:
close in interface Database

Parameters:
stmt - The Statement object to be closed.

close

public void close(java.sql.ResultSet rs)
Close a result set, ignoring any errors.
Specified by:
close in interface Database

Parameters:
rs - The ResultSet object to be closed.

close

public void close(java.sql.ResultSet rs,
                  java.sql.Statement stmt)
Close a statement and resultset, ignoring errors.
Specified by:
close in interface Database

Parameters:
rs - The ResultSet object to be closed.
stmt - The Statement object to be closed.
con - The Connection object to be closed.

readFromClob

public java.lang.String readFromClob(java.sql.Clob clob)
                              throws java.sql.SQLException
Reads the contents of a Clob and returns as a String.
Specified by:
readFromClob in interface Database


readFromClob

public java.lang.String readFromClob(java.sql.ResultSet resultSet,
                                     int index)
                              throws java.sql.SQLException


close

public void close(java.io.Reader reader)
Specified by:
close in interface Database


close

public void close(java.io.Writer writer)
Specified by:
close in interface Database


writeToClob

public void writeToClob(java.sql.Clob clob,
                        java.lang.String data)
                 throws java.sql.SQLException
Writes the data from the String into the Clob.
Specified by:
writeToClob in interface Database


writeToClob

public java.io.Reader writeToClob(java.sql.PreparedStatement statement,
                                  int index,
                                  java.lang.String data)
                           throws java.sql.SQLException


startClob

public void startClob()
               throws java.sql.SQLException
setAutoCommit( false ) on the Connection
Specified by:
startClob in interface Database


endClob

public void endClob()
             throws java.sql.SQLException
Call Connection.commit
Specified by:
endClob in interface Database


insertClob

public void insertClob(ClobKey key,
                       java.lang.String data)
                throws java.sql.SQLException
Inserts a CLOB into the database managed tables for CLOB persistence


removeClob

public void removeClob(ClobKey key)
                throws java.sql.SQLException
Removes a CLOB from the database managed tables for CLOB persistence


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


readClob

public java.lang.String readClob(ClobKey key)
                          throws java.sql.SQLException
Reads a CLOB into the database managed tables for CLOB persistence


createClobKey

public ClobKey createClobKey(java.lang.String namespace,
                             java.lang.String identifier)
Creates an instance of ClobKey for the given namespace and identifier.


getApplicationName

public java.lang.String getApplicationName()
Get the name of the current WebLogic J2EE application or return null if not running within a WebLogic J2EE context.
Specified by:
getApplicationName in interface Database


getClobTableName

public java.lang.String getClobTableName()

Returns:
the name of the database table used to persist CLOB datatypes.

getName

public java.lang.String getName()
Specified by:
getName in interface Database

Returns:
the name of the database

getEmptyClobInitializer

public java.lang.String getEmptyClobInitializer()
                                         throws java.sql.SQLException
Specified by:
getEmptyClobInitializer in interface Database


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
Specified by:
getClobLocator in interface Database


getClob

public java.lang.String getClob(java.sql.ResultSet rs,
                                int index)
                         throws java.sql.SQLException
Specified by:
getClob in interface Database


setClob

public void setClob(java.sql.PreparedStatement stmt,
                    int index,
                    java.lang.String str)
             throws java.sql.SQLException
Specified by:
setClob in interface Database


setClob

public boolean setClob(java.sql.PreparedStatement stmt,
                       int index,
                       java.sql.Clob clob,
                       java.lang.String str)
                throws java.sql.SQLException
Specified by:
setClob in interface Database


commitConnection

public boolean commitConnection(java.sql.Connection connection)
                         throws java.sql.SQLException
Specified by:
commitConnection in interface Database


getProperty

protected java.lang.String getProperty(java.lang.String propertyName)


printSqlWarning

protected void printSqlWarning(java.sql.SQLWarning warning)


createPreparedStatement

protected java.sql.PreparedStatement createPreparedStatement(java.lang.String key)
                                                      throws java.sql.SQLException


© 2002 BEA Systems, Inc.

Copyright © 2002 BEA Systems, Inc. All Rights Reserved