org.apache.ojb.broker.platforms
Interface Platform

All Known Implementing Classes:
PlatformDefaultImpl

public interface Platform

this interface provides callbacks that allow to perform RDBMS Platform specific operations whereever neccessary. The Platform implementation is selected by the entry in the repository.xml file.

Version:
$Id: Platform.java,v 1.22 2004/02/21 21:41:45 brj Exp $
Author:
Thomas Mahler

Method Summary
 void addBatch(java.sql.PreparedStatement stmt)
           
 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 StatementManager implementation after invoke stmt.close() method.
 void afterStatementCreate(java.sql.Statement stmt)
          Called after a jdbc-m_connection statement was created.
 void beforeBatch(java.sql.PreparedStatement stmt)
           
 void beforeStatementClose(java.sql.Statement stmt, java.sql.ResultSet rs)
          Called by StatementManager implementation before invoke 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)
          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)
           
 java.lang.String getEscapeClause(LikeCriteria aCriteria)
          Answer the Clause used Escape wildcards in LIKE
 byte getJoinSyntaxType()
          Get join syntax type for this RDBMS - one on of the constants from JoinSyntaxType 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)
          callback called immediately after a JDBC Connection has been obtained in ...
 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 setNullForStatement(java.sql.PreparedStatement ps, int index, int sqlType)
          some JDBC-Drivers do not support all sqlTypes this callback is used set parameters to a PreparedStatement
 void setObjectForStatement(java.sql.PreparedStatement ps, int index, java.lang.Object value, int sqlType)
          some JDBC-Drivers do not support all sqlTypes this callback is used set parameters to a PreparedStatement
 boolean supportsBatchOperations()
          if this platform supports the batch operations jdbc 2.0 feature.
 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

public void afterStatementCreate(java.sql.Statement stmt)
                          throws PlatformException
Called after a jdbc-m_connection statement was created.

Throws:
PlatformException

beforeStatementClose

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

Throws:
PlatformException

afterStatementClose

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

Throws:
PlatformException

beforeBatch

public void beforeBatch(java.sql.PreparedStatement stmt)
                 throws PlatformException
Parameters:
stmt - the statement you want to batch on
Throws:
PlatformException

addBatch

public void addBatch(java.sql.PreparedStatement stmt)
              throws PlatformException
Parameters:
stmt - the statement you are adding to the batch
Throws:
PlatformException

executeBatch

public int[] executeBatch(java.sql.PreparedStatement stmt)
                   throws PlatformException
Parameters:
stmt - the statement you want to execute the batch on
Throws:
PlatformException

initializeJdbcConnection

public void initializeJdbcConnection(JdbcConnectionDescriptor jcd,
                                     java.sql.Connection conn)
                              throws PlatformException
callback called immediately after a JDBC Connection has been obtained in ...

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

changeAutoCommitState

public 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

public void setObjectForStatement(java.sql.PreparedStatement ps,
                                  int index,
                                  java.lang.Object value,
                                  int sqlType)
                           throws java.sql.SQLException
some JDBC-Drivers do not support all sqlTypes this callback is used set parameters to a PreparedStatement

Throws:
java.sql.SQLException

setNullForStatement

public void setNullForStatement(java.sql.PreparedStatement ps,
                                int index,
                                int sqlType)
                         throws java.sql.SQLException
some JDBC-Drivers do not support all sqlTypes this callback is used set parameters to a PreparedStatement

Throws:
java.sql.SQLException

getJoinSyntaxType

public byte getJoinSyntaxType()
Get join syntax type for this RDBMS - one on of the constants from JoinSyntaxType interface


useCountForResultsetSize

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


supportsBatchOperations

public 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

public java.lang.String createSequenceQuery(java.lang.String sequenceName)
Returns a query to create a sequence entry.

Returns:
a sql string to create a sequence

nextSequenceQuery

public 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

public 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

public 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

public 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

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

Returns:

addPagingSql

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


bindPagingParametersFirst

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

Returns:

bindPagingParameters

public 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 -
Returns:
Throws:
java.sql.SQLException

concatenate

public 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

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

Parameters:
aCriteria -
Returns:


Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14