|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
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 CallableStatementpublic PreparedStatement createPreparedStatement(String queryName, Connection connection) throws StatementFactoryException
createPreparedStatement
in interface StatementFactory
queryName
- query to create a CallableStatement for.connection
- a connection to execute with.
StatementFactoryException
- indicates an error
creating the CallableStatementpublic 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()
- Specified by:
createPreparedStatement
in interface StatementFactory
- Parameters:
queryName
- query to create a CallableStatement for.
- Returns:
- a PreparedStatement constructed for the queryName given
- Throws:
StatementFactoryException
- indicates an error
creating the CallableStatement
buildCallableStatement
protected CallableStatement buildCallableStatement(StatementConfiguration statementConfig,
Connection connection)
throws SQLException
- Builds a callable statement for the given configuration
with the connection given.
- Parameters:
statementConfig
- configuration to build the statement fromconnection
- a connection to execute with.
- Returns:
- a CallableStatement constructed for the queryName given
- Throws:
SQLException
- indicates an error
creating the CallableStatement
createCallableStatement
public CallableStatement createCallableStatement(String queryName,
Connection connection)
throws StatementFactoryException
- Creates a callable statement for the given query name
with the connection given.
- Specified by:
createCallableStatement
in interface StatementFactory
- Parameters:
queryName
- query to create a CallableStatement for.connection
- a connection to execute with.
- Returns:
- a CallableStatement constructed for the queryName given
- Throws:
StatementFactoryException
- indicates an error
creating the CallableStatement
createCallableStatement
public CallableStatement createCallableStatement(String queryName)
throws StatementFactoryException
- Creates a callable statement for the given query name using
the default connection in the factories configuration.
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()
- Specified by:
createCallableStatement
in interface StatementFactory
- Parameters:
queryName
- query to create a CallableStatement for.
- Returns:
- a CallableStatement constructed for the queryName given
- Throws:
StatementFactoryException
- indicates an error
creating the CallableStatement
retrieveConfiguration
protected StatementConfiguration retrieveConfiguration(String queryName,
Class sourceClass)
throws StatementNotConfiguredException
- Looks up a statement configuration based on the name of
the configuration.
- Parameters:
queryName
- name of the query to lookupsourceClass
- class to use when throwing an exception
- Returns:
- a StatementConfiguration for the given queryName
- Throws:
StatementNotConfiguredException
- indicates the queryName had no
configured statement associated with it.
configure
public void configure(ComponentConfiguration configuration)
- Configure the component. This is preceded and followed by the suspend and
resume operations if they are available on the component.
- Specified by:
configure
in interface Configurable
- Parameters:
configuration
- A SqlFactoryConfiguration
configureStatement
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.
- Parameters:
statement
- A PreparedStatement
or a
CallableStatement>
sqlStatement
- The configuration information for the statement.
- Returns:
- Statement A configured statement
- Throws:
SQLException
- indicates an error configuring the statement
buildDebugMessage
protected String buildDebugMessage(StatementConfiguration statementConfig)
- Builds a debug message containg the configuration status of the supplied
configured statement.
- Parameters:
statementConfig
- statement configuration to build debug
message for
- Returns:
- a debug message describing the statement config
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Copyright 1999-2003 Sapient Corporation. All Rights Reserved.