@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
Constructor and Description |
---|
JdbcStoredProcedureProducer() |
Modifier and Type | Method and Description |
---|---|
protected long |
defaultTimeout()
The default timeout for request messages when not supplied.
|
protected void |
doProduce(AdaptrisMessage msg,
java.lang.String endpoint)
Actually do the produce.
|
protected AdaptrisMessage |
doRequest(AdaptrisMessage msg,
java.lang.String endpoint,
long timeout)
Actually do the request.
|
java.lang.String |
endpoint(AdaptrisMessage msg)
Return the endpoint that will be derived from the message.
|
ProduceDestination |
getDestination()
Deprecated.
|
InOutParameters |
getInOutParameters() |
InParameters |
getInParameters() |
OutParameters |
getOutParameters() |
java.lang.String |
getProcedureName()
The name of the stored procedure.
|
ResultSetTranslator |
getResultSetTranslator() |
CallableStatementCreator |
getStatementCreator() |
CallableStatementExecutor |
getStatementExecutor() |
TimeInterval |
getTimeout() |
void |
prepare()
Prepare for initialisation.
|
void |
setDestination(ProduceDestination destination)
Deprecated.
|
void |
setInOutParameters(InOutParameters inOutParameters) |
void |
setInParameters(InParameters inParameters) |
void |
setOutParameters(OutParameters outParameters) |
void |
setProcedureName(java.lang.String procedureName)
The name of the stored procedure.
|
void |
setResultSetTranslator(ResultSetTranslator resultSetTranslator) |
void |
setStatementCreator(CallableStatementCreator statementCreator) |
void |
setStatementExecutor(CallableStatementExecutor statementExecutor) |
void |
setTimeout(TimeInterval timeout) |
produce, produce, request, request, request, request
copyReplyContents, getIgnoreReplyMetadata, mergeReply, setIgnoreReplyMetadata
createName
createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
close, init, start, stop
createQualifier, isTrackingEndpoint
protected AdaptrisMessage doRequest(AdaptrisMessage msg, java.lang.String endpoint, long timeout) throws ProduceException
RequestReplyProducerImp
doRequest
in class RequestReplyProducerImp
ProduceException
protected void doProduce(AdaptrisMessage msg, java.lang.String endpoint) throws ProduceException
RequestReplyProducerImp
doProduce
in class RequestReplyProducerImp
ProduceException
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()
RequestReplyProducerBase
defaultTimeout
in class RequestReplyProducerBase
public TimeInterval getTimeout()
public void setTimeout(TimeInterval timeout)
public java.lang.String endpoint(AdaptrisMessage msg) throws ProduceException
AdaptrisMessageProducerImp
The purpose of this method is to mitigate the number of changes that need to happen because
ProduceDestination
is being deprecated; boilerplate code can still be present in the
parent super-classes w/o impacting concrete sub-classes "too much".
endpoint
in class AdaptrisMessageProducerImp
ProduceException
AdaptrisMessageProducer.request(AdaptrisMessage, ProduceDestination)
,
AdaptrisMessageProducer.request(AdaptrisMessage, ProduceDestination, long)
,
AdaptrisMessageSender.produce(AdaptrisMessage)
,
AdaptrisMessageSender.produce(AdaptrisMessage, ProduceDestination)
@Deprecated public ProduceDestination getDestination()
@Deprecated public void setDestination(ProduceDestination destination)
public java.lang.String getProcedureName()
public void setProcedureName(java.lang.String procedureName)