@ComponentProfile(summary="Execute a stored procedure via JDBC", tag="producer,jdbc", recommended=DatabaseConnection.class) public class JdbcStoredProcedureProducer extends RequestReplyProducerImp
To specify your chosen database vendor, you will set the CallableStatementCreator
to one of the
following
implementations; MysqlStatementCreator
or OracleStatementCreator
, other types
of database can be directly
supported by using ConfiguredStatementCreator
. Generally, ProduceDestination
will be used to derive the stored procedure to execute.
You may also set parameters (In, Out and InOut) for your Stored Procedure. Both the "In" and the "InOut" parameters will retrieve
their data from the AdaptrisMessage
and that data will be passed into the stored procedure. Both the
"Out" and "InOut"
parameters will have the result from the Stored Procedure re-applied back into the AdaptrisMessage
. The
method with which
these parameters get or apply their values to and from the AdaptrisMessage
will depend on the parameter
implementation
chosen, see the sub classes of AbstractParameter
To set the parameters for your Stored Procedure configure the following;
- InParameters
- OutParameters
- InOutParameters
Each parameter you set, must include one of either the Order or the Name. The name of the parameter is mapped the parameter name
of the Stored Procedure, the Order will define the order.Stored Procedures, as well as returning data through Out and InOut
parameters, may also return data through a ResultSet
. In fact, Stored Procedures may return multiple ResultSet
's.
ResultSet
's may also be applied back into the AdaptrisMessage
To define the behaviour
of applying
ResultSet
's back into the AdaptrisMessage
set the translator for this producer, see
ResultSetTranslator
Note; if your Stored Procedure returns multiple result sets, each will be applied back into your AdaptrisMessage
using
the ResultSetTranslator
configured.
If you plan on using this producer for Microsoft SQL Server, we recommend using a driver that is fully JDBC 3.0 compliant. The standard Microsoft JDBC driver does not support multiple open result sets, therefore if your stored procedure returns multiple result sets, we recommend using a fully compliant JDBC 3.0 driver such as the JTDS driver.
Finally, the default timeout set for the database operation is 0 (i.e. no timeout). You can override this by configuring the
"timeout" field with a TimeInterval
In the adapter configuration file this class is aliased as jdbc-stored-procedure-producer which is the preferred alternative to the fully qualified classname when building your configuration.
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
JdbcStoredProcedureProducer() |
getIgnoreReplyMetadata, produce, request, request, request, request, setIgnoreReplyMetadata, shouldIgnoreReplyMetadata
getDestination, setDestination
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
createName, createQualifier, isTrackingEndpoint
protected AdaptrisMessage doRequest(AdaptrisMessage msg, ProduceDestination destination, long timeout) throws ProduceException
RequestReplyProducerImp
doRequest
in class RequestReplyProducerImp
ProduceException
#request(AdaptrisMessage,
ProduceDestination, long)
public void produce(AdaptrisMessage msg, ProduceDestination destination) throws ProduceException
AdaptrisMessageSender
AdaptrisMessage
to the supplied ProduceDestination
, over-riding any configured destinations.msg
- the AdaptrisMessage
to producedestination
- the ProduceDestination
to produce toProduceException
- wrapping any underlying Exceptionspublic void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
CoreException
- wrapping any underlying Exception
spublic void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.
CoreException
- wrapping any underlying Exception
spublic void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing a
RuntimeException
may cause unintended consequences
public void close()
ComponentLifecycle
A closed component should release any connections it uses, etc. and clean up completely.
Throwing a RuntimeException
may cause unintended consequences
public void prepare() throws CoreException
ComponentLifecycleExtension
CoreException
public InParameters getInParameters()
public void setInParameters(InParameters inParameters)
public OutParameters getOutParameters()
public void setOutParameters(OutParameters outParameters)
public InOutParameters getInOutParameters()
public void setInOutParameters(InOutParameters inOutParameters)
public CallableStatementCreator getStatementCreator()
public void setStatementCreator(CallableStatementCreator statementCreator)
public CallableStatementExecutor getStatementExecutor()
public void setStatementExecutor(CallableStatementExecutor statementExecutor)
public ResultSetTranslator getResultSetTranslator()
public void setResultSetTranslator(ResultSetTranslator resultSetTranslator)
protected long defaultTimeout()
RequestReplyProducerImp
defaultTimeout
in class RequestReplyProducerImp
public TimeInterval getTimeout()
public void setTimeout(TimeInterval timeout)