org.apache.ojb.broker.platforms
Class PlatformOracle9iImpl

java.lang.Object
  extended by org.apache.ojb.broker.platforms.PlatformDefaultImpl
      extended by org.apache.ojb.broker.platforms.PlatformOracleImpl
          extended by org.apache.ojb.broker.platforms.PlatformOracle9iImpl
All Implemented Interfaces:
JoinSyntaxTypes, Platform

public class PlatformOracle9iImpl
extends PlatformOracleImpl

This class is a concrete implementation of Platform. Provides an implementation that works around some issues with Oracle in general and Oracle 9i's Thin driver in particular. NOTE: When using BEA WebLogic and BLOB/CLOB datatypes, the physical connection will be used causing WebLogic to mark it as "infected" and discard it when the logicical connection is closed. You can change this behavior by setting the RemoveInfectedConnectionsEnabled attribute on a connection pool. see WebLogic docs. Optimization: Oracle Batching (not standard JDBC batching) see http://technet.oracle.com/products/oracle9i/daily/jun07.html Optimization: Oracle Prefetching see http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/advanced/RowPrefetchSample/Readme.html Optimization: Oracle Statement Caching see http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/jdbc30/StmtCacheSample/Readme.html TODO: Optimization: use ROWNUM to minimize the effects of not having server side cursors see http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:127412348064

Version:
CVS $Id: PlatformOracle9iImpl.java,v 1.1 2007-08-24 22:17:35 ewestfal Exp $
Author:
Matthew Baird, Martin Kalén, Contributions from: Erik Forkalsrud, Danilo Tommasina, Thierry Hanot, Don Lyon
See Also:
Platform, PlatformDefaultImpl, PlatformOracleImpl

Field Summary
protected static Class JBOSS_CONN_CLASS
           
protected static String JBOSS_CONN_NAME
           
private  Logger logger
           
protected static Map m_batchStatementsInProgress
           
protected static Method METHOD_SET_BLOB
           
protected static Method METHOD_SET_CLOB
           
protected static Method METHOD_SET_IMPLICIT_CACHING_ENABLED
           
protected static Method METHOD_SET_ROW_PREFETCH
           
protected static Method METHOD_SET_STATEMENT_CACHE_SIZE
           
protected static Class ORA_BLOB_CLASS
           
protected static boolean ORA_BLOB_HANDLING_AVAILABLE
           
protected static Class ORA_CLOB_CLASS
           
protected static boolean ORA_CLOB_HANDLING_AVAILABLE
           
protected static Class ORA_CONN_CLASS
           
protected static Class ORA_PS_CLASS
           
protected static boolean ORA_ROW_PREFETCH_AVAILABLE
           
protected static boolean ORA_STATEMENT_CACHING_AVAILABLE
           
protected static Object[] PARAM_BOOLEAN_TRUE
           
protected static Object[] PARAM_EMPTY
           
protected static Object[] PARAM_ROW_PREFETCH_SIZE
           
protected static Object[] PARAM_STATEMENT_BATCH_SIZE
           
protected static Object[] PARAM_STATEMENT_CACHE_SIZE
           
protected static Class[] PARAM_TYPE_BOOLEAN
           
protected static Class[] PARAM_TYPE_EMPTY
           
protected static Class[] PARAM_TYPE_INT_ORABLOB
           
protected static Class[] PARAM_TYPE_INT_ORACLOB
           
protected static Class[] PARAM_TYPE_INTEGER
           
protected static Class[] PARAM_TYPE_STRING
           
protected static int ROW_PREFETCH_SIZE
          Number of rows pre-fetched by the JDBC-driver for each executed query, when using Oracle row pre-fetching with OracleConnections.
protected static int STATEMENT_CACHE_SIZE
          Number of cached statements per connection, when using implicit caching with OracleConnections.
protected static int STATEMENTS_PER_BATCH
           
protected static String[] UNWRAP_CONN_METHOD_NAMES
          Method names used by unwrapConnection(java.sql.Connection).
protected static Class[][] UNWRAP_CONN_PARAM_TYPES
          Method parameter signature used by unwrapConnection(java.sql.Connection) for corresponding UNWRAP_CONN_METHOD_NAMES-index.
protected static String[] UNWRAP_PS_METHOD_NAMES
          Method names used by unwrapStatement(java.sql.Statement).
protected static Class[][] UNWRAP_PS_PARAM_TYPES
          Method parameter signature used by unwrapStatement(java.sql.Statement) for corresponding UNWRAP_PS_METHOD_NAMES-index.
 
Fields inherited from class org.apache.ojb.broker.platforms.PlatformOracleImpl
ORACLE_JDBC_TYPE_CURSOR, THIN_BLOB_MAX_SIZE, THIN_CLOB_MAX_SIZE, THIN_URL_PREFIX
 
Fields inherited from class org.apache.ojb.broker.platforms.PlatformDefaultImpl
log, m_batchUpdatesChecked, m_supportsBatchUpdates
 
Fields inherited from interface org.apache.ojb.broker.accesslayer.JoinSyntaxTypes
ORACLE_JOIN_SYNTAX, SQL92_JOIN_SYNTAX, SQL92_NOPAREN_JOIN_SYNTAX, SYBASE_JOIN_SYNTAX
 
Constructor Summary
PlatformOracle9iImpl()
          Default constructor.
 
Method Summary
 void addBatch(PreparedStatement stmt)
          Try Oracle update batching and call executeUpdate or revert to JDBC update batching.
 void afterStatementCreate(Statement stmt)
          Performs platform-specific operations on each statement.
 void beforeBatch(PreparedStatement stmt)
          Try Oracle update batching and call setExecuteBatch or revert to JDBC update batching.
 int[] executeBatch(PreparedStatement stmt)
          Try Oracle update batching and call sendBatch or revert to JDBC update batching.
protected  Object genericUnwrap(Class classToMatch, Object toUnwrap, String[] methodNameCandidates, Class[][] methodTypeCandidates)
           
 byte getJoinSyntaxType()
          Get join syntax type for this RDBMS.
 void initializeJdbcConnection(JdbcConnectionDescriptor jcd, Connection conn)
          Enables Oracle statement caching and row prefetching if supported by the JDBC-driver.
protected  void initOracleReflectedVars()
          Initializes static variables needed for Oracle-extensions and large BLOB/CLOB support.
 void setObjectForStatement(PreparedStatement ps, int index, Object value, int sqlType)
          For objects beyond 4k, weird things happen in Oracle if you try to use "setBytes", so for all cases it's better to use setBinaryStream.
protected  Connection unwrapConnection(Connection conn)
          Return an OracleConnection after trying to unwrap from known Connection wrappers.
protected  Statement unwrapStatement(Statement ps)
          Return an OraclePreparedStatement after trying to unwrap from known Statement wrappers.
 
Methods inherited from class org.apache.ojb.broker.platforms.PlatformOracleImpl
changePreparedStatementResultSetType, createSequenceQuery, createSequenceQuery, dropSequenceQuery, isUsingOracleThinDriver, nextSequenceQuery, prepareNextValProcedureStatement, registerOutResultSet
 
Methods inherited from class org.apache.ojb.broker.platforms.PlatformDefaultImpl
addPagingSql, afterStatementClose, beforeStatementClose, bindPagingParameters, bindPagingParametersFirst, changeAutoCommitState, checkForBatchSupport, concatenate, getConcatenationCharacter, getEscapeClause, getLastInsertIdentityQuery, setNullForStatement, supportsBatchOperations, supportsMultiColumnCountDistinct, supportsPaging, useCountForResultsetSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private Logger logger

STATEMENT_CACHE_SIZE

protected static final int STATEMENT_CACHE_SIZE
Number of cached statements per connection, when using implicit caching with OracleConnections. Set in initializeJdbcConnection(org.apache.ojb.broker.metadata.JdbcConnectionDescriptor, java.sql.Connection).

See Also:
Profiling page for a discussion re sizing, Constant Field Values

ROW_PREFETCH_SIZE

protected static final int ROW_PREFETCH_SIZE
Number of rows pre-fetched by the JDBC-driver for each executed query, when using Oracle row pre-fetching with OracleConnections. Set in initializeJdbcConnection(org.apache.ojb.broker.metadata.JdbcConnectionDescriptor, java.sql.Connection).

Note: this setting can be overridden by specifying a connection-pool attribute with name="jdbc.defaultRowPrefetch". Oracle JDBC-driver default value=10.

See Also:
Constant Field Values

STATEMENTS_PER_BATCH

protected static final int STATEMENTS_PER_BATCH
See Also:
Constant Field Values

m_batchStatementsInProgress

protected static Map m_batchStatementsInProgress

PARAM_TYPE_EMPTY

protected static final Class[] PARAM_TYPE_EMPTY

PARAM_TYPE_INTEGER

protected static final Class[] PARAM_TYPE_INTEGER

PARAM_TYPE_BOOLEAN

protected static final Class[] PARAM_TYPE_BOOLEAN

PARAM_TYPE_STRING

protected static final Class[] PARAM_TYPE_STRING

PARAM_EMPTY

protected static final Object[] PARAM_EMPTY

PARAM_STATEMENT_CACHE_SIZE

protected static final Object[] PARAM_STATEMENT_CACHE_SIZE

PARAM_ROW_PREFETCH_SIZE

protected static final Object[] PARAM_ROW_PREFETCH_SIZE

PARAM_STATEMENT_BATCH_SIZE

protected static final Object[] PARAM_STATEMENT_BATCH_SIZE

PARAM_BOOLEAN_TRUE

protected static final Object[] PARAM_BOOLEAN_TRUE

JBOSS_CONN_NAME

protected static final String JBOSS_CONN_NAME
See Also:
Constant Field Values

JBOSS_CONN_CLASS

protected static Class JBOSS_CONN_CLASS

ORA_CONN_CLASS

protected static Class ORA_CONN_CLASS

ORA_PS_CLASS

protected static Class ORA_PS_CLASS

ORA_CLOB_CLASS

protected static Class ORA_CLOB_CLASS

ORA_BLOB_CLASS

protected static Class ORA_BLOB_CLASS

PARAM_TYPE_INT_ORACLOB

protected static Class[] PARAM_TYPE_INT_ORACLOB

PARAM_TYPE_INT_ORABLOB

protected static Class[] PARAM_TYPE_INT_ORABLOB

METHOD_SET_STATEMENT_CACHE_SIZE

protected static Method METHOD_SET_STATEMENT_CACHE_SIZE

METHOD_SET_IMPLICIT_CACHING_ENABLED

protected static Method METHOD_SET_IMPLICIT_CACHING_ENABLED

METHOD_SET_ROW_PREFETCH

protected static Method METHOD_SET_ROW_PREFETCH

METHOD_SET_BLOB

protected static Method METHOD_SET_BLOB

METHOD_SET_CLOB

protected static Method METHOD_SET_CLOB

ORA_STATEMENT_CACHING_AVAILABLE

protected static boolean ORA_STATEMENT_CACHING_AVAILABLE

ORA_ROW_PREFETCH_AVAILABLE

protected static boolean ORA_ROW_PREFETCH_AVAILABLE

ORA_CLOB_HANDLING_AVAILABLE

protected static boolean ORA_CLOB_HANDLING_AVAILABLE

ORA_BLOB_HANDLING_AVAILABLE

protected static boolean ORA_BLOB_HANDLING_AVAILABLE

UNWRAP_CONN_METHOD_NAMES

protected static final String[] UNWRAP_CONN_METHOD_NAMES
Method names used by unwrapConnection(java.sql.Connection).


UNWRAP_CONN_PARAM_TYPES

protected static final Class[][] UNWRAP_CONN_PARAM_TYPES
Method parameter signature used by unwrapConnection(java.sql.Connection) for corresponding UNWRAP_CONN_METHOD_NAMES-index. If signature is not PARAM_TYPE_EMPTY, the actual connection object will be passed at runtime. (NB: Requires special handling of param type in constructor.)


UNWRAP_PS_METHOD_NAMES

protected static final String[] UNWRAP_PS_METHOD_NAMES
Method names used by unwrapStatement(java.sql.Statement).


UNWRAP_PS_PARAM_TYPES

protected static final Class[][] UNWRAP_PS_PARAM_TYPES
Method parameter signature used by unwrapStatement(java.sql.Statement) for corresponding UNWRAP_PS_METHOD_NAMES-index. If signature is not PARAM_TYPE_EMPTY, the actual Statement object will be passed at runtime. (NB: Requires special handling of param type in constructor.)

Constructor Detail

PlatformOracle9iImpl

public PlatformOracle9iImpl()
Default constructor.

Method Detail

initializeJdbcConnection

public void initializeJdbcConnection(JdbcConnectionDescriptor jcd,
                                     Connection conn)
                              throws PlatformException
Enables Oracle statement caching and row prefetching if supported by the JDBC-driver.

Specified by:
initializeJdbcConnection in interface Platform
Overrides:
initializeJdbcConnection in class PlatformDefaultImpl
Parameters:
jcd - the OJB JdbcConnectionDescriptor (metadata) for the connection to be initialized
conn - the Connection-object (physical) to be initialized
Throws:
PlatformException
See Also:
PlatformDefaultImpl.initializeJdbcConnection(org.apache.ojb.broker.metadata.JdbcConnectionDescriptor, java.sql.Connection), Oracle TechNet Statement Caching Sample, Oracle TechNet Row Pre-fetch Sample

afterStatementCreate

public void afterStatementCreate(Statement stmt)
Performs platform-specific operations on each statement.

Specified by:
afterStatementCreate in interface Platform
Overrides:
afterStatementCreate in class PlatformOracleImpl
Parameters:
stmt - the statement just created

beforeBatch

public void beforeBatch(PreparedStatement stmt)
                 throws PlatformException
Try Oracle update batching and call setExecuteBatch or revert to JDBC update batching. See 12-2 Update Batching in the Oracle9i JDBC Developer's Guide and Reference.

Specified by:
beforeBatch in interface Platform
Overrides:
beforeBatch in class PlatformDefaultImpl
Parameters:
stmt - the prepared statement to be used for batching
Throws:
PlatformException - upon JDBC failure

addBatch

public void addBatch(PreparedStatement stmt)
              throws PlatformException
Try Oracle update batching and call executeUpdate or revert to JDBC update batching.

Specified by:
addBatch in interface Platform
Overrides:
addBatch in class PlatformDefaultImpl
Parameters:
stmt - the statement beeing added to the batch
Throws:
PlatformException - upon JDBC failure

executeBatch

public int[] executeBatch(PreparedStatement stmt)
                   throws PlatformException
Try Oracle update batching and call sendBatch or revert to JDBC update batching.

Specified by:
executeBatch in interface Platform
Overrides:
executeBatch in class PlatformDefaultImpl
Parameters:
stmt - the batched prepared statement about to be executed
Returns:
always null if Oracle update batching is used, since it is impossible to dissolve total row count into distinct statement counts. If JDBC update batching is used, an int array is returned containing number of updated rows for each batched statement.
Throws:
PlatformException - upon JDBC failure

setObjectForStatement

public void setObjectForStatement(PreparedStatement ps,
                                  int index,
                                  Object value,
                                  int sqlType)
                           throws SQLException
Description copied from class: PlatformOracleImpl
For objects beyond 4k, weird things happen in Oracle if you try to use "setBytes", so for all cases it's better to use setBinaryStream. Oracle also requires a change in the resultset type of the prepared statement. MBAIRD NOTE: BLOBS may not work with Oracle database/thin driver versions prior to 8.1.6.

Specified by:
setObjectForStatement in interface Platform
Overrides:
setObjectForStatement in class PlatformOracleImpl
Throws:
SQLException
See Also:
Platform.setObjectForStatement(java.sql.PreparedStatement, int, java.lang.Object, int)

getJoinSyntaxType

public byte getJoinSyntaxType()
Get join syntax type for this RDBMS.

Specified by:
getJoinSyntaxType in interface Platform
Overrides:
getJoinSyntaxType in class PlatformOracleImpl
Returns:
SQL92_NOPAREN_JOIN_SYNTAX
See Also:
Platform.getJoinSyntaxType()

unwrapConnection

protected Connection unwrapConnection(Connection conn)
Return an OracleConnection after trying to unwrap from known Connection wrappers.

Parameters:
conn - the connection to unwrap (if needed)
Returns:
OracleConnection or null if not able to unwrap

unwrapStatement

protected Statement unwrapStatement(Statement ps)
Return an OraclePreparedStatement after trying to unwrap from known Statement wrappers.

Parameters:
ps - the PreparedStatement to unwrap (if needed)
Returns:
OraclePreparedStatement or null if not able to unwrap

genericUnwrap

protected Object genericUnwrap(Class classToMatch,
                               Object toUnwrap,
                               String[] methodNameCandidates,
                               Class[][] methodTypeCandidates)

initOracleReflectedVars

protected void initOracleReflectedVars()
Initializes static variables needed for Oracle-extensions and large BLOB/CLOB support.

Overrides:
initOracleReflectedVars in class PlatformOracleImpl


Copyright © 2007-2012 The Kuali Foundation. All Rights Reserved.