void applyCustomizers(final StatementType stmt, Object[] args) { statementCustomizers.forEach(b -> { try { b.apply(stmt, args); } catch (SQLException e) { throw new UnableToExecuteStatementException(e, stmt.getContext()); } }); }
/** * @return the finalized {@link ParsedSql} object. */ public ParsedSql build() { if (positional && named) { throw new UnableToExecuteStatementException( "Cannot mix named and positional parameters in a SQL statement: " + parameterNames); } ParsedParameters parameters = new ParsedParameters(positional, parameterNames); return new ParsedSql(sql.toString(), parameters); } }
final void callCustomizers(StatementCustomizerInvocation invocation) { for (StatementCustomizer customizer : getCustomizers()) { try { invocation.call(customizer); } catch (SQLException e) { throw new UnableToExecuteStatementException("Exception thrown in statement customization", e, ctx); } } }
throw new UnableToExecuteStatementException("Could not get OUT parameter from statement", e, getContext());
throw new UnableToExecuteStatementException("Unable to configure JDBC statement", e, getContext()); return SqlLoggerUtil.wrap(stmt::executeBatch, getContext(), getConfig(SqlStatements.class).getSqlLogger()); } catch (SQLException e) { throw new UnableToExecuteStatementException(mungeBatchException(e), getContext());
throw new UnableToExecuteStatementException("Exception while binding parameters", e, getContext()); throw new UnableToExecuteStatementException(Batch.mungeBatchException(e), getContext());
throw new UnableToExecuteStatementException(e, ctx);
final void beforeExecution(final PreparedStatement stmt) { for (StatementCustomizer customizer : customizers) { try { customizer.beforeExecution(stmt, ctx); } catch (SQLException e) { throw new UnableToExecuteStatementException("Exception thrown in statement customization", e, ctx); } } }
final void afterExecution(final PreparedStatement stmt) { for (StatementCustomizer customizer : customizers) { try { customizer.afterExecution(stmt, ctx); } catch (SQLException e) { throw new UnableToExecuteStatementException("Exception thrown in statement customization", e, ctx); } } }
/** * @return the finalized {@link ParsedSql} object. */ public ParsedSql build() { if (positional && named) { throw new UnableToExecuteStatementException( "Cannot mix named and positional parameters in a SQL statement: " + parameterNames); } ParsedParameters parameters = new ParsedParameters(positional, parameterNames); return new ParsedSql(sql.toString(), parameters); } }
private static void bindNamed(List<String> parameterNames, Binding binding, PreparedStatement statement, StatementContext context) { for (int i = 0; i < parameterNames.size(); i++) { String param = parameterNames.get(i); try { binding.findForName(param, context) .orElseThrow(() -> new UnableToExecuteStatementException( String.format("Unable to execute, no named parameter matches '%s'.", param), context)) .apply(i + 1, statement, context); } catch (SQLException e) { throw new UnableToCreateStatementException( String.format("Exception while binding named parameter '%s'", param), e, context); } } } }
private static void bindPositional(int size, Binding binding, PreparedStatement statement, StatementContext context) { for (int i = 0; i < size; i++) { try { Argument argument = binding.findForPosition(i).orElse(null); if (argument != null) { argument.apply(i + 1, statement, context); } // any missing positional parameters could be return parameters } catch (SQLException e) { throw new UnableToExecuteStatementException( "Exception while binding positional param at (0 based) position " + i, e, context); } } }
throw new UnableToExecuteStatementException("Unable to configure JDBC statement", e, getContext()); throw new UnableToExecuteStatementException(mungeBatchException(e), getContext());
throw new UnableToExecuteStatementException("Could not get OUT parameter from statement", e, getContext());
throw new UnableToExecuteStatementException("Exception while binding parameters", e, getContext()); throw new UnableToExecuteStatementException(Batch.mungeBatchException(e), getContext());
e.addSuppressed(e1); throw new UnableToExecuteStatementException(e, getContext());