Overview | Package | Class | Tree | Deprecated | Index | Help
| © 2002 BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.p13n.util.jdbc
Interface Database

All Known Implementing Classes:
  GenericDatabase

public interface Database

Provides various CLOB-handling methods, as well as validity-checking for various database drivers. Sub-classed by `GenericDatabase`.

See Also:
  `GenericDatabase`

Method Summary
`boolean` | `accept(java.sql.Connection connection)`
`void` | `close()` Close the Connection associated with this Database
`void` | `close(java.io.Reader reader)` Closes a Reader ignoring any exceptions.
`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 connection, statement and resultset, ignoring errors.
`void` | `close(java.sql.Statement stmt)` Close a statement, ignoring any errors.
`void` | `close(java.io.Writer writer)` Closes a Writer ignoring any exceptions.
`boolean` | `commitConnection(java.sql.Connection connection)`
`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)` Get the value of a CLOB column as a string.
`java.sql.Clob` | `getClobLocator(java.sql.Connection con, java.lang.String tableName, java.lang.String clobColumnName, java.lang.String whereClause)`
`java.sql.Connection` | `getConnection()`
`java.lang.String` | `getEmptyClobInitializer()`
`java.lang.String` | `getName()`
`java.lang.String` | `readFromClob(java.sql.Clob clob)` Reads the contents of a Clob and returns as a String.
`boolean` | `setClob(java.sql.PreparedStatement stmt, int index, java.sql.Clob clob, java.lang.String str)` If there is a delegate, this method uses JdbcHelperDelegate.writeClobData().
`void` | `setClob(java.sql.PreparedStatement stmt, int index, java.lang.String str)` Set the value of a CLOB column with a string.
`void` | `startClob()` setAutoCommit( false ) on the Connection
`void` | `writeToClob(java.sql.Clob clob, java.lang.String data)` Writes the data from the String into the Clob.

Method Detail

### getConnection

    public java.sql.Connection getConnection()

  Returns:
    the Connection associated with the Database

### accept

    public boolean accept(java.sql.Connection connection)

  Returns:
    true if this Database can bind to the supplied connection. Typically the Database will examine the Connection MetaData to determine suitability.

### close

    public void close()

  Close the Connection associated with this Database

### close

    public void close(java.io.Reader reader)

  Closes a Reader ignoring any exceptions.

### close

    public void close(java.io.Writer writer)

  Closes a Writer ignoring any exceptions.

### close

    public void close(java.sql.Statement stmt)

  Close a statement, ignoring any errors.

  Parameters:
    `stmt` - The Statement object to be closed.

### close

    public void close(java.sql.ResultSet rs)

  Close a result set, ignoring any errors.

  Parameters:
    `rs` - The ResultSet object to be closed.

### close

    public void close(java.sql.ResultSet rs,
                      java.sql.Statement stmt)

  Close a connection, statement and resultset, ignoring errors.

  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.

### 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.

### startClob

    public void startClob()
                   throws java.sql.SQLException

  setAutoCommit( false ) on the Connection

### endClob

    public void endClob()
                 throws java.sql.SQLException

  Call Connection.commit

### 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.

### getName

    public java.lang.String getName()

  Returns:
    the name of the database

### getEmptyClobInitializer

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

### 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

### getClob

    public java.lang.String getClob(java.sql.ResultSet rs,
                                    int index)
                             throws java.sql.SQLException

  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.

  Parameters:
    `rs` - the result set.
    `index` - the column index in the result set.
  Returns:
    the column as a string.
  Throws:
    java.sql.SQLException - thrown on an error.

### setClob

    public void setClob(java.sql.PreparedStatement stmt,
                        int index,
                        java.lang.String str)
                 throws java.sql.SQLException

  Set the value of a CLOB column with a string.

  Parameters:
    `stmt` - the prepared statement.
    `index` - the column index.
    `str` - the CLOB string.
  Throws:
    java.sql.SQLException - thrown on an error.

### setClob

    public boolean setClob(java.sql.PreparedStatement stmt,
                           int index,
                           java.sql.Clob clob,
                           java.lang.String str)
                    throws java.sql.SQLException

  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.

  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:
    java.sql.SQLException - thrown on an error.

### commitConnection

    public boolean commitConnection(java.sql.Connection connection)
                             throws java.sql.SQLException

Overview | Package | Class | Tree | Deprecated | Index | Help
| © 2002 BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 BEA Systems, Inc. All Rights Reserved