Package 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
Modifier and TypeMethodDescriptionIterator
<?> 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 statementprepareQuery
(String query, boolean allowNamedParameters, org.apache.camel.Exchange exchange) Prepares the query to be executed.
-
Method Details
-
prepareQuery
String prepareQuery(String query, boolean allowNamedParameters, org.apache.camel.Exchange exchange) throws SQLException Prepares the query to be executed.- Parameters:
query
- the query which may contain named query parametersallowNamedParameters
- whether named parameters is allowedexchange
- the current exchange- 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 parameterspreparedQuery
- the query to actually use, which must be accepted by the JDBC driver.expectedParams
- number of expected parametersexchange
- the current exchangevalue
- 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 statementiterator
- the iterator to use for getting the parameter dataexpectedParams
- number of expected parameters- Throws:
SQLException
- is thrown if error populating parameters
-