|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.sape.carbon.services.sql.DefaultStatementFactoryImpl
The default implementation for the StatementFactory. The configuration
interface for this component is
SqlFactoryConfiguration.
The Component configuration consists of
<!-- Component Configuration for a SQLStatementFactory -->
<Configuration ConfigurationInterface=
"org.sape.carbon.services.sql.SqlFactoryConfiguration">
<FunctionalInterface>
org.sape.carbon.services.sql.StatementFactory
</FunctionalInterface>
<FunctionalImplementationClass>
org.sape.carbon.services.sql.DefaultStatementFactoryImpl
</FunctionalImplementationClass>
<ConnectionFactory>
ref:///sql/connection/test/StandaloneConnectionFactory
</ConnectionFactory>
<!-- Default Values for Statement Properties -->
<ResultSetType>TYPE_SCROLL_SENSITIVE</ResultSetType>
<ResultSetConcurrency>CONCUR_UPDATABLE</ResultSetConcurrency>
<MaxRows>5</MaxRows>
<!-- Statement Definitions -->
<Statement>
<!-- Statement Query Name -->
<QueryName>selectAccounts</QueryName>
<Query>SELECT * FROM accounts</Query>
<!-- Overriding Parameters -->
<MaxRows>10</MaxRows>
</Statement>
<Statement>
<QueryName>Second</QueryName>
<Query>SELECT * from TEST</Query>
</Statement>
</Configuration>
| Field Summary | |
protected StatementFactoryConfiguration |
config
Holds a reference to this factories configuration. |
protected static String |
CONNECTION_FACTORY_CONFIGURATION_ERROR
Holds the error message displayed if the user has not properly configured a connection factory. |
private org.apache.commons.logging.Log |
log
Provides a handle to Apache-commons logger |
protected static String |
RESULT_SET_CONFIGURATION_ERROR
Holds the error message displayed if the user has not properly configured the result set type and concurrency. |
protected String |
statementFactoryName
The name of this factory. |
protected Map |
statementsMap
Holds the map of all query name to StatementConfigurations. |
| Constructor Summary | |
DefaultStatementFactoryImpl()
|
|
| Method Summary | |
protected CallableStatement |
buildCallableStatement(StatementConfiguration statementConfig,
Connection connection)
Builds a callable statement for the given configuration with the connection given. |
protected String |
buildDebugMessage(StatementConfiguration statementConfig)
Builds a debug message containg the configuration status of the supplied configured statement. |
protected PreparedStatement |
buildPreparedStatement(StatementConfiguration statementConfig,
Connection connection)
Builds a prepared statement for the given configuration with the connection given. |
void |
configure(ComponentConfiguration configuration)
Configure the component. |
protected Statement |
configureStatement(Statement statement,
StatementConfiguration sqlStatement)
Configure the statement based on the configuration specified in the sqlStatement or using the default values. |
CallableStatement |
createCallableStatement(String queryName)
Creates a callable statement for the given query name using the default connection in the factories configuration. |
CallableStatement |
createCallableStatement(String queryName,
Connection connection)
Creates a callable statement for the given query name with the connection given. |
PreparedStatement |
createPreparedStatement(String queryName)
Creates a prepared statement for the given query name using the default connection in the factories configuration. |
PreparedStatement |
createPreparedStatement(String queryName,
Connection connection)
Creates a prepared statement for the given query name with the connection given. |
protected StatementConfiguration |
retrieveConfiguration(String queryName,
Class sourceClass)
Looks up a statement configuration based on the name of the configuration. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private org.apache.commons.logging.Log log
protected String statementFactoryName
protected StatementFactoryConfiguration config
protected Map statementsMap
protected static final String RESULT_SET_CONFIGURATION_ERROR
protected static final String CONNECTION_FACTORY_CONFIGURATION_ERROR
| Constructor Detail |
public DefaultStatementFactoryImpl()
| Method Detail |
protected PreparedStatement buildPreparedStatement(StatementConfiguration statementConfig,
Connection connection)
throws SQLException
statementConfig - configuration to build the statement fromconnection - a connection to execute with.
SQLException - indicates an error
creating the CallableStatement
public PreparedStatement createPreparedStatement(String queryName,
Connection connection)
throws StatementFactoryException
createPreparedStatement in interface StatementFactoryqueryName - query to create a CallableStatement for.connection - a connection to execute with.
StatementFactoryException - indicates an error
creating the CallableStatement
public PreparedStatement createPreparedStatement(String queryName)
throws StatementFactoryException
When using this interface to create a statement it is important to remember to get back and close the connection that is created. This should be done with:
statement.getConnection().close()
createPreparedStatement in interface StatementFactoryqueryName - query to create a CallableStatement for.
StatementFactoryException - indicates an error
creating the CallableStatement
protected CallableStatement buildCallableStatement(StatementConfiguration statementConfig,
Connection connection)
throws SQLException
statementConfig - configuration to build the statement fromconnection - a connection to execute with.
SQLException - indicates an error
creating the CallableStatement
public CallableStatement createCallableStatement(String queryName,
Connection connection)
throws StatementFactoryException
createCallableStatement in interface StatementFactoryqueryName - query to create a CallableStatement for.connection - a connection to execute with.
StatementFactoryException - indicates an error
creating the CallableStatement
public CallableStatement createCallableStatement(String queryName)
throws StatementFactoryException
When using this interface to create a statement it is important to remember to get back and close the connection that is created. This should be done with:
statement.getConnection().close()
createCallableStatement in interface StatementFactoryqueryName - query to create a CallableStatement for.
StatementFactoryException - indicates an error
creating the CallableStatement
protected StatementConfiguration retrieveConfiguration(String queryName,
Class sourceClass)
throws StatementNotConfiguredException
queryName - name of the query to lookupsourceClass - class to use when throwing an exception
StatementNotConfiguredException - indicates the queryName had no
configured statement associated with it.public void configure(ComponentConfiguration configuration)
configure in interface Configurableconfiguration - A SqlFactoryConfiguration
protected Statement configureStatement(Statement statement,
StatementConfiguration sqlStatement)
throws SQLException
Configure the statement based on the configuration specified in the sqlStatement or using the default values.
statement - A PreparedStatement or a
CallableStatement>sqlStatement - The configuration information for the statement.
SQLException - indicates an error configuring the statementprotected String buildDebugMessage(StatementConfiguration statementConfig)
statementConfig - statement configuration to build debug
message for
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||