Package org.apache.camel.component.sql
Class DefaultSqlPrepareStatementStrategy
- java.lang.Object
-
- org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy
-
- All Implemented Interfaces:
SqlPrepareStatementStrategy
public class DefaultSqlPrepareStatementStrategy extends Object implements SqlPrepareStatementStrategy
DefaultSqlPrepareStatementStrategythat supports named query parameters as well index based.
-
-
Constructor Summary
Constructors Constructor Description DefaultSqlPrepareStatementStrategy()DefaultSqlPrepareStatementStrategy(char separator)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static org.springframework.util.CompositeIteratorcreateInParameterIterator(Object value)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.protected booleanhasNamedParameters(String query)protected static booleanhasParameter(String nextParam, org.apache.camel.Exchange exchange, Object body)protected static ObjectlookupParameter(String nextParam, org.apache.camel.Exchange exchange, Object body)voidpopulateStatement(PreparedStatement ps, Iterator<?> iterator, int expectedParams)Populates the query parameters on the prepared statementStringprepareQuery(String query, boolean allowNamedParameters, org.apache.camel.Exchange exchange)Prepares the query to be executed.
-
-
-
Method Detail
-
prepareQuery
public String prepareQuery(String query, boolean allowNamedParameters, org.apache.camel.Exchange exchange) throws SQLException
Description copied from interface:SqlPrepareStatementStrategyPrepares the query to be executed.- Specified by:
prepareQueryin interfaceSqlPrepareStatementStrategy- 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
public Iterator<?> createPopulateIterator(String query, String preparedQuery, int expectedParams, org.apache.camel.Exchange exchange, Object value) throws SQLException
Description copied from interface:SqlPrepareStatementStrategyCreates the iterator to use when setting query parameters on the prepared statement.- Specified by:
createPopulateIteratorin interfaceSqlPrepareStatementStrategy- 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
public void populateStatement(PreparedStatement ps, Iterator<?> iterator, int expectedParams) throws SQLException
Description copied from interface:SqlPrepareStatementStrategyPopulates the query parameters on the prepared statement- Specified by:
populateStatementin interfaceSqlPrepareStatementStrategy- 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
-
hasNamedParameters
protected boolean hasNamedParameters(String query)
-
lookupParameter
protected static Object lookupParameter(String nextParam, org.apache.camel.Exchange exchange, Object body)
-
hasParameter
protected static boolean hasParameter(String nextParam, org.apache.camel.Exchange exchange, Object body)
-
createInParameterIterator
protected static org.springframework.util.CompositeIterator createInParameterIterator(Object value)
-
-