Search in sources :

Example 1 with StoredProcedure

use of com.adaptris.jdbc.StoredProcedure in project interlok by adaptris.

the class JdbcStoredProcedureProducer method doRequest.

@Override
protected AdaptrisMessage doRequest(AdaptrisMessage msg, String endpoint, long timeout) throws ProduceException {
    Connection connection = null;
    JdbcResult results = null;
    try {
        connection = getConnection(msg);
        StoredProcedure storedProcedure = new StoredProcedure();
        storedProcedure.setConnection(connection);
        storedProcedure.setName(endpoint);
        storedProcedure.setStatementCreator(getStatementCreator());
        storedProcedure.setParameters(parseInParameters(msg));
        storedProcedure.setStatementExecutor(getStatementExecutor());
        storedProcedure.setTimeout(defaultTimeout());
        storedProcedure.setAdaptrisMessage(msg);
        storedProcedure.setResultSetTranslator(getResultSetTranslator());
        results = storedProcedure.execute();
        parseOutParameters(msg, results.getParameters());
        commit(connection, msg);
    } catch (Exception e) {
        rollback(connection, msg);
        throw new ProduceException(e);
    } finally {
        JdbcUtil.closeQuietly(results);
        JdbcUtil.closeQuietly(connection);
    }
    return msg;
}
Also used : StoredProcedure(com.adaptris.jdbc.StoredProcedure) Connection(java.sql.Connection) JdbcResult(com.adaptris.jdbc.JdbcResult) ProduceException(com.adaptris.core.ProduceException) SQLException(java.sql.SQLException) ProduceException(com.adaptris.core.ProduceException)

Aggregations

ProduceException (com.adaptris.core.ProduceException)1 JdbcResult (com.adaptris.jdbc.JdbcResult)1 StoredProcedure (com.adaptris.jdbc.StoredProcedure)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1