org.apache.camel.component.sql
Interface SqlPrepareStatementStrategy

All Known Implementing Classes:
DefaultSqlPrepareStatementStrategy

public interface SqlPrepareStatementStrategy

Strategy for preparing statements when executing SQL queries.


Method Summary
 Iterator<?> createPopulateIterator(String query, String preparedQuery, int expectedParams, org.apache.camel.Exchange exchange, Object value)
          Creates the iterator to use when setting query parameters on the prepared statement.
 void populateStatement(PreparedStatement ps, Iterator<?> iterator, int expectedParams)
          Populates the query parameters on the prepared statement
 String prepareQuery(String query, boolean allowNamedParameters)
          Prepares the query to be executed.
 

Method Detail

prepareQuery

String prepareQuery(String query,
                    boolean allowNamedParameters)
                    throws SQLException
Prepares the query to be executed.

Parameters:
query - the query which may contain named query parameters
allowNamedParameters - whether named parameters is allowed
Returns:
the query to actually use, which must be accepted by the JDBC driver.
Throws:
SQLException

createPopulateIterator

Iterator<?> createPopulateIterator(String query,
                                   String preparedQuery,
                                   int expectedParams,
                                   org.apache.camel.Exchange exchange,
                                   Object value)
                                   throws SQLException
Creates the iterator to use when setting query parameters on the prepared statement.

Parameters:
query - the original query which may contain named parameters
preparedQuery - the query to actually use, which must be accepted by the JDBC driver.
expectedParams - number of expected parameters
exchange - the current exchange
value - the message body that contains the data for the query parameters
Returns:
the iterator
Throws:
SQLException - is thrown if error creating the iterator

populateStatement

void populateStatement(PreparedStatement ps,
                       Iterator<?> iterator,
                       int expectedParams)
                       throws SQLException
Populates the query parameters on the prepared statement

Parameters:
ps - the prepared statement
iterator - the iterator to use for getting the parameter data
expectedParams - number of expected parameters
Throws:
SQLException - is thrown if error populating parameters


Apache Camel