org.apache.camel.component.sql
Class DefaultSqlPrepareStatementStrategy

java.lang.Object
  extended by org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy
All Implemented Interfaces:
SqlPrepareStatementStrategy

public class DefaultSqlPrepareStatementStrategy
extends Object
implements SqlPrepareStatementStrategy

Default SqlPrepareStatementStrategy that supports named query parameters as well index based.


Constructor Summary
DefaultSqlPrepareStatementStrategy()
           
DefaultSqlPrepareStatementStrategy(char separator)
           
 
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.
protected  boolean hasNamedParameters(String query)
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSqlPrepareStatementStrategy

public DefaultSqlPrepareStatementStrategy()

DefaultSqlPrepareStatementStrategy

public DefaultSqlPrepareStatementStrategy(char separator)
Method Detail

prepareQuery

public String prepareQuery(String query,
                           boolean allowNamedParameters)
                    throws SQLException
Description copied from interface: SqlPrepareStatementStrategy
Prepares the query to be executed.

Specified by:
prepareQuery in interface SqlPrepareStatementStrategy
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

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

Specified by:
createPopulateIterator in interface SqlPrepareStatementStrategy
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

public void populateStatement(PreparedStatement ps,
                              Iterator<?> iterator,
                              int expectedParams)
                       throws SQLException
Description copied from interface: SqlPrepareStatementStrategy
Populates the query parameters on the prepared statement

Specified by:
populateStatement in interface SqlPrepareStatementStrategy
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

hasNamedParameters

protected boolean hasNamedParameters(String query)


Apache Camel