@Test public void testParameterApplicator() throws Exception { parameterApplicator.applyStatementParameters(message, mockStatement, parameters, twoParamSqlStatement); verify(mockStatement).setObject(1, "MyValue1"); verify(mockStatement).setObject(2, "MyValue2"); }
@Override public void applyStatementParameters(AdaptrisMessage message, PreparedStatement statement, StatementParameterCollection parameters, String originalSql) throws ServiceException { Matcher m = Pattern.compile(this.getParameterNameRegex()).matcher(originalSql); int counter = 0; while (m.find()) { counter++; String parameterName = m.group(); JdbcStatementParameter statementParameter = parameters.getParameterByName(parameterName.substring(this.getParameterNamePrefix() .length())); try { Args.notNull(statementParameter, "statementParameter"); statementParameter.apply(counter, statement, message); } catch (Exception ex) { throw ExceptionHelper.wrapServiceException(ex); } } }
NamedParameterApplicator implements ParameterApplicator { @Override public void applyStatementParameters(AdaptrisMessage message, PreparedStatement statement, StatementParameterCollection parameters, String originalSql) throws ServiceException { Matcher m = Pattern.compile(this.getParameterNameRegex()).matcher(originalSql); int counter = 0; while (m.find()) { counter++; String parameterName = m.group(); JdbcStatementParameter statementParameter = parameters.getParameterByName(parameterName.substring(this.getParameterNamePrefix() .length())); try { Args.notNull(statementParameter, "statementParameter"); statementParameter.apply(counter, statement, message); } catch (Exception ex) { throw ExceptionHelper.wrapServiceException(ex); } } } }
NamedParameterApplicator implements ParameterApplicator { @Override public void applyStatementParameters(AdaptrisMessage message, PreparedStatement statement, StatementParameterCollection parameters, String originalSql) throws ServiceException { Matcher m = Pattern.compile(this.getParameterNameRegex()).matcher(originalSql); int counter = 0; while (m.find()) { counter++; String parameterName = m.group(); JdbcStatementParameter statementParameter = parameters.getParameterByName(parameterName.substring(this.getParameterNamePrefix() .length())); try { Args.notNull(statementParameter, "statementParameter"); statementParameter.apply(counter, statement, message); } catch (Exception ex) { throw ExceptionHelper.wrapServiceException(ex); } } } NamedParameterApplicator(); }
NamedParameterApplicator implements ParameterApplicator { @Override public void applyStatementParameters(AdaptrisMessage message, PreparedStatement statement, StatementParameterCollection parameters, String originalSql) throws ServiceException { Matcher m = Pattern.compile(this.getParameterNameRegex()).matcher(originalSql); int counter = 0; while (m.find()) { counter++; String parameterName = m.group(); JdbcStatementParameter statementParameter = parameters.getParameterByName(parameterName.substring(this.getParameterNamePrefix() .length())); try { Args.notNull(statementParameter, "statementParameter"); statementParameter.apply(counter, statement, message); } catch (Exception ex) { throw ExceptionHelper.wrapServiceException(ex); } } } NamedParameterApplicator(); @Override void applyStatementParameters(AdaptrisMessage message, PreparedStatement statement,
                                       StatementParameterCollection parameters, String originalSql); @Override String prepareParametersToStatement(String originalStatement); String getParameterNamePrefix(); void setParameterNamePrefix(String s); String getParameterNameRegex(); void setParameterNameRegex(String regex); }
NamedParameterApplicator implements ParameterApplicator { @Override public void applyStatementParameters(AdaptrisMessage message, PreparedStatement statement, StatementParameterCollection parameters, String originalSql) throws ServiceException { Matcher m = Pattern.compile(this.getParameterNameRegex()).matcher(originalSql); int counter = 0; while (m.find()) { counter++; String parameterName = m.group(); JdbcStatementParameter statementParameter = parameters.getParameterByName(parameterName.substring(this.getParameterNamePrefix() .length())); try { Args.notNull(statementParameter, "statementParameter"); statementParameter.apply(counter, statement, message); } catch (Exception ex) { throw ExceptionHelper.wrapServiceException(ex); } } } NamedParameterApplicator(); @Override void applyStatementParameters(AdaptrisMessage message, PreparedStatement statement,
                                       StatementParameterCollection parameters, String originalSql); @Override String prepareParametersToStatement(String originalStatement); String getParameterNamePrefix(); void setParameterNamePrefix(String s); String getParameterNameRegex(); void setParameterNameRegex(String regex); static final String DEFAULT_PARAM_NAME_PREFIX; static final String DEFAULT_PARAM_NAME_REGEX; }