Search in sources :

Example 1 with EmptySqlParameterSource

use of org.springframework.jdbc.core.namedparam.EmptySqlParameterSource in project camel by apache.

the class ElsqlEndpoint method createConsumer.

@Override
public Consumer createConsumer(final Processor processor) throws Exception {
    final SqlProcessingStrategy proStrategy = new ElsqlSqlProcessingStrategy(elSql);
    final SqlPrepareStatementStrategy preStategy = new ElsqlSqlPrepareStatementStrategy();
    final SqlParameterSource param = new EmptySqlParameterSource();
    final String sql = elSql.getSql(elsqlName, new SpringSqlParams(param));
    LOG.debug("ElsqlConsumer @{} using sql: {}", elsqlName, sql);
    final ElsqlConsumer consumer = new ElsqlConsumer(this, processor, namedJdbcTemplate, sql, param, preStategy, proStrategy);
    consumer.setMaxMessagesPerPoll(getMaxMessagesPerPoll());
    consumer.setOnConsume(getOnConsume());
    consumer.setOnConsumeFailed(getOnConsumeFailed());
    consumer.setOnConsumeBatchComplete(getOnConsumeBatchComplete());
    consumer.setBreakBatchOnConsumeFail(isBreakBatchOnConsumeFail());
    consumer.setExpectedUpdateCount(getExpectedUpdateCount());
    consumer.setUseIterator(isUseIterator());
    consumer.setRouteEmptyResultSet(isRouteEmptyResultSet());
    configureConsumer(consumer);
    return consumer;
}
Also used : SqlProcessingStrategy(org.apache.camel.component.sql.SqlProcessingStrategy) EmptySqlParameterSource(org.springframework.jdbc.core.namedparam.EmptySqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) SqlPrepareStatementStrategy(org.apache.camel.component.sql.SqlPrepareStatementStrategy) DefaultSqlPrepareStatementStrategy(org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy) EmptySqlParameterSource(org.springframework.jdbc.core.namedparam.EmptySqlParameterSource) SpringSqlParams(com.opengamma.elsql.SpringSqlParams)

Example 2 with EmptySqlParameterSource

use of org.springframework.jdbc.core.namedparam.EmptySqlParameterSource in project camel by apache.

the class ElsqlSqlProcessingStrategy method commitBatchComplete.

@Override
public int commitBatchComplete(DefaultSqlEndpoint endpoint, NamedParameterJdbcTemplate namedJdbcTemplate, SqlParameterSource parameterSource, String query) throws Exception {
    final SqlParameterSource param = new EmptySqlParameterSource();
    final String sql = elSql.getSql(query, new SpringSqlParams(param));
    LOG.debug("commitBatchComplete @{} using sql: {}", query, sql);
    return namedJdbcTemplate.execute(sql, param, new PreparedStatementCallback<Integer>() {

        @Override
        public Integer doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
            ps.execute();
            int updateCount = ps.getUpdateCount();
            if (LOG.isTraceEnabled()) {
                LOG.trace("Update count {}", updateCount);
            }
            return updateCount;
        }
    });
}
Also used : EmptySqlParameterSource(org.springframework.jdbc.core.namedparam.EmptySqlParameterSource) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) SQLException(java.sql.SQLException) EmptySqlParameterSource(org.springframework.jdbc.core.namedparam.EmptySqlParameterSource) PreparedStatement(java.sql.PreparedStatement) DataAccessException(org.springframework.dao.DataAccessException) SpringSqlParams(com.opengamma.elsql.SpringSqlParams)

Aggregations

SpringSqlParams (com.opengamma.elsql.SpringSqlParams)2 EmptySqlParameterSource (org.springframework.jdbc.core.namedparam.EmptySqlParameterSource)2 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)2 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 DefaultSqlPrepareStatementStrategy (org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy)1 SqlPrepareStatementStrategy (org.apache.camel.component.sql.SqlPrepareStatementStrategy)1 SqlProcessingStrategy (org.apache.camel.component.sql.SqlProcessingStrategy)1 DataAccessException (org.springframework.dao.DataAccessException)1