org.apache.ojb.broker.platforms
Interface Platform

All Known Implementing Classes:
PlatformDb2Impl, PlatformDefaultImpl, PlatformDerbyImpl, PlatformFirebirdImpl, PlatformHsqldbImpl, PlatformInformixImpl, PlatformMaxDBImpl, PlatformMsAccessImpl, PlatformMsSQLServerImpl, PlatformMySQLImpl, PlatformOracle9iImpl, PlatformOracleImpl, PlatformPostgreSQLImpl, PlatformSapdbImpl, PlatformSybaseASAImpl, PlatformSybaseASEImpl, PlatformSybaseImpl, PlatformWLOracle9iImpl

public interface Platform

This interface provides callbacks that allow to perform RDBMS Platform specific operations wherever neccessary. The Platform implementation is selected by the platform attribute for each jdbc-connection-descriptor entry in the repository file.

Version:
$Id: Platform.java 365226 2005-12-18 16:43:19Z tomdz $
Author:
Thomas Mahler

Method Summary
 void addBatch(java.sql.PreparedStatement stmt)
          Called when adding statements to current batch.
 void addPagingSql(java.lang.StringBuffer anSqlString)
          Add the LIMIT or equivalent to the SQL SQL-Paging is not yet supported
 void afterStatementClose(java.sql.Statement stmt, java.sql.ResultSet rs)
          Called by StatementManagerIF implementation after invoking stmt.close() method.
 void afterStatementCreate(java.sql.Statement stmt)
          Called after a statement has been created.
 void beforeBatch(java.sql.PreparedStatement stmt)
          Called before batching operations on a statement.
 void beforeStatementClose(java.sql.Statement stmt, java.sql.ResultSet rs)
          Called by StatementManagerIF implementation before invoking stmt.close() method.
 int bindPagingParameters(java.sql.PreparedStatement ps, int index, int startAt, int endAt)
          Bind the Paging Parameters SQL-Paging is not yet supported
 boolean bindPagingParametersFirst()
          Answer true if the LIMIT parameters are bound before the query parameters SQL-Paging is not yet supported
 void changeAutoCommitState(JdbcConnectionDescriptor jcd, java.sql.Connection con, boolean newState)
          Used to do a temporary change of the m_connection autoCommit state.
 java.lang.String concatenate(java.lang.String[] theColumns)
          Concatenate the columns
ie: col1 || col2 || col3 (ANSI)
ie: col1 + col2 + col3 (MS SQL-Server)
ie: concat(col1, col2, col3) (MySql)
 java.lang.String createSequenceQuery(java.lang.String sequenceName)
          Deprecated. use createSequenceQuery(String) instead.
 java.lang.String createSequenceQuery(java.lang.String sequenceName, java.util.Properties prop)
          Returns a query to create a sequence entry.
 java.lang.String dropSequenceQuery(java.lang.String sequenceName)
          Returns a query to drop a sequence entry.
 int[] executeBatch(java.sql.PreparedStatement stmt)
          Executes current batch.
 java.lang.String getEscapeClause(LikeCriteria aCriteria)
          Answer the Clause used Escape wildcards in LIKE
 byte getJoinSyntaxType()
          Get join syntax type for this RDBMS - one of the constants from JoinSyntaxTypes interface.
 java.lang.String getLastInsertIdentityQuery(java.lang.String tableName)
          If database supports native key generation via identity column, this method should return the sql-query to obtain the last generated id.
 void initializeJdbcConnection(JdbcConnectionDescriptor jcd, java.sql.Connection conn)
          Called immediately after a JDBC connection has been created by a ConnectionFactory implementation (not used for DataSource connections).
 java.lang.String nextSequenceQuery(java.lang.String sequenceName)
          Returns a query to obtain the next sequence key.
 java.sql.CallableStatement prepareNextValProcedureStatement(java.sql.Connection con, java.lang.String procedureName, java.lang.String sequenceName)
          Create stored procedure call for a special sequence manager implementation SequenceManagerStoredProcedureImpl, because it seems that jdbc-driver differ in handling of CallableStatement.
 void registerOutResultSet(java.sql.CallableStatement stmt, int position)
          Registers call argument at position as returning a ResultSet value.
 void setNullForStatement(java.sql.PreparedStatement ps, int index, int sqlType)
          Called to let the Platform implementation perform any JDBC type-specific operations needed by the driver when binding null parameters for a PreparedStatement.
 void setObjectForStatement(java.sql.PreparedStatement ps, int index, java.lang.Object value, int sqlType)
          Called to let the Platform implementation perform any JDBC type-specific operations needed by the driver when binding positional parameters for a PreparedStatement.
 boolean supportsBatchOperations()
          If this platform supports the batch operations jdbc 2.0 feature.
 boolean supportsMultiColumnCountDistinct()
          Whether the platform supports a COUNT DISTINCT across multiple columns.
 boolean supportsPaging()
          Answer true if LIMIT or equivalent is supported SQL-Paging is not yet supported
 boolean useCountForResultsetSize()
          Override default ResultSet size determination (rs.last();rs.getRow()) with select count(*) operation.
 

Method Detail

afterStatementCreate

void afterStatementCreate(java.sql.Statement stmt)
                          throws PlatformException
Called after a statement has been created.

Throws:
PlatformException

beforeStatementClose

void beforeStatementClose(java.sql.Statement stmt,
                          java.sql.ResultSet rs)
                          throws PlatformException
Called by StatementManagerIF implementation before invoking stmt.close() method.

Throws:
PlatformException

afterStatementClose

void afterStatementClose(java.sql.Statement stmt,
                         java.sql.ResultSet rs)
                         throws PlatformException
Called by StatementManagerIF implementation after invoking stmt.close() method.

Throws:
PlatformException

beforeBatch

void beforeBatch(java.sql.PreparedStatement stmt)
                 throws PlatformException
Called before batching operations on a statement.

Parameters:
stmt - the statement you want to batch on
Throws:
PlatformException

addBatch

void addBatch(java.sql.PreparedStatement stmt)
              throws PlatformException
Called when adding statements to current batch.

Parameters:
stmt - the statement you are adding to the batch
Throws:
PlatformException

executeBatch

int[] executeBatch(java.sql.PreparedStatement stmt)
                   throws PlatformException
Executes current batch.

Parameters:
stmt - the statement you want to execute the batch on
Throws:
PlatformException

initializeJdbcConnection

void initializeJdbcConnection(JdbcConnectionDescriptor jcd,
                              java.sql.Connection conn)
                              throws PlatformException
Called immediately after a JDBC connection has been created by a ConnectionFactory implementation (not used for DataSource connections).

Parameters:
conn - the Connection to be initialized
Throws:
PlatformException

changeAutoCommitState

void changeAutoCommitState(JdbcConnectionDescriptor jcd,
                           java.sql.Connection con,
                           boolean newState)
Used to do a temporary change of the m_connection autoCommit state. When using this method ensure to reset the original state before m_connection was returned to pool or closed. Only when JdbcConnectionDescriptor.getUseAutoCommit() was set to JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE the change of the autoCommit state take effect.


setObjectForStatement

void setObjectForStatement(java.sql.PreparedStatement ps,
                           int index,
                           java.lang.Object value,
                           int sqlType)
                           throws java.sql.SQLException
Called to let the Platform implementation perform any JDBC type-specific operations needed by the driver when binding positional parameters for a PreparedStatement.

Throws:
java.sql.SQLException

setNullForStatement

void setNullForStatement(java.sql.PreparedStatement ps,
                         int index,
                         int sqlType)
                         throws java.sql.SQLException
Called to let the Platform implementation perform any JDBC type-specific operations needed by the driver when binding null parameters for a PreparedStatement.

Throws:
java.sql.SQLException

getJoinSyntaxType

byte getJoinSyntaxType()
Get join syntax type for this RDBMS - one of the constants from JoinSyntaxTypes interface.

See Also:
JoinSyntaxTypes.SQL92_JOIN_SYNTAX, JoinSyntaxTypes.SQL92_NOPAREN_JOIN_SYNTAX, JoinSyntaxTypes.ORACLE_JOIN_SYNTAX, JoinSyntaxTypes.SYBASE_JOIN_SYNTAX

useCountForResultsetSize

boolean useCountForResultsetSize()
Override default ResultSet size determination (rs.last();rs.getRow()) with select count(*) operation.


supportsBatchOperations

boolean supportsBatchOperations()
If this platform supports the batch operations jdbc 2.0 feature. This is by driver, so we check the driver's metadata once and set something in the platform.

Returns:
true if the platform supports batch, false otherwise.

createSequenceQuery

java.lang.String createSequenceQuery(java.lang.String sequenceName,
                                     java.util.Properties prop)
Returns a query to create a sequence entry.

Parameters:
sequenceName - The name of the sequence to create.
prop - The database specific sequence properties.
Returns:
a sql string to create a sequence

createSequenceQuery

java.lang.String createSequenceQuery(java.lang.String sequenceName)
Deprecated. use createSequenceQuery(String) instead.

Returns a query to create a sequence entry.

Parameters:
sequenceName - The name of the sequence to create.
Returns:
a sql string to create a sequence

nextSequenceQuery

java.lang.String nextSequenceQuery(java.lang.String sequenceName)
Returns a query to obtain the next sequence key.

Returns:
a sql string to get next sequence value

dropSequenceQuery

java.lang.String dropSequenceQuery(java.lang.String sequenceName)
Returns a query to drop a sequence entry.

Returns:
a sql string to drop a sequence

prepareNextValProcedureStatement

java.sql.CallableStatement prepareNextValProcedureStatement(java.sql.Connection con,
                                                            java.lang.String procedureName,
                                                            java.lang.String sequenceName)
                                                            throws PlatformException
Create stored procedure call for a special sequence manager implementation SequenceManagerStoredProcedureImpl, because it seems that jdbc-driver differ in handling of CallableStatement.
Note: The out-parameter of the stored procedure must be registered at first position, because lookup for new long id in the implementation:
 Connection con = broker.serviceConnectionManager().getConnection();
 cs = getPlatform().prepareNextValProcedureStatement(con, PROCEDURE_NAME, sequenceName);
 cs.executeUpdate();
 return cs.getLong(1);
 

Throws:
PlatformException

getLastInsertIdentityQuery

java.lang.String getLastInsertIdentityQuery(java.lang.String tableName)
If database supports native key generation via identity column, this method should return the sql-query to obtain the last generated id.


supportsPaging

boolean supportsPaging()
Answer true if LIMIT or equivalent is supported SQL-Paging is not yet supported


addPagingSql

void addPagingSql(java.lang.StringBuffer anSqlString)
Add the LIMIT or equivalent to the SQL SQL-Paging is not yet supported


bindPagingParametersFirst

boolean bindPagingParametersFirst()
Answer true if the LIMIT parameters are bound before the query parameters SQL-Paging is not yet supported


bindPagingParameters

int bindPagingParameters(java.sql.PreparedStatement ps,
                         int index,
                         int startAt,
                         int endAt)
                         throws java.sql.SQLException
Bind the Paging Parameters SQL-Paging is not yet supported

Parameters:
ps -
index - parameter index
startAt -
endAt -
Throws:
java.sql.SQLException

supportsMultiColumnCountDistinct

boolean supportsMultiColumnCountDistinct()
Whether the platform supports a COUNT DISTINCT across multiple columns.

Returns:
true if it is supported

concatenate

java.lang.String concatenate(java.lang.String[] theColumns)
Concatenate the columns
ie: col1 || col2 || col3 (ANSI)
ie: col1 + col2 + col3 (MS SQL-Server)
ie: concat(col1, col2, col3) (MySql)

Parameters:
theColumns -
Returns:
the concatenated String

getEscapeClause

java.lang.String getEscapeClause(LikeCriteria aCriteria)
Answer the Clause used Escape wildcards in LIKE

Parameters:
aCriteria -

registerOutResultSet

void registerOutResultSet(java.sql.CallableStatement stmt,
                          int position)
                          throws java.sql.SQLException
Registers call argument at position as returning a ResultSet value.

Parameters:
stmt - the statement
position - argument position
Throws:
java.sql.SQLException


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30