title: Apache camel how to insert map value to data base using sql component
body: <p>Apache camel how to insert map value to data base using SQL component</p>
  
  <p>My Class file:</p>
  
  <pre><code>public class PolluxDataController  {
  
      List&lt;PolluxData&gt; stationsMasterList=new ArrayList&lt;PolluxData&gt;();
      List&lt;PolluxData&gt; stationProccessedList=new ArrayList&lt;PolluxData&gt;();
      Map&lt;String,Object&gt; stationMap=new HashMap&lt;String,Object&gt;();
  
  
      @SuppressWarnings("unchecked")
      public Map&lt;String, Object&gt; processPolluxData(Exchange exchange) throws Exception {
  
          stationsMasterList= (List&lt;PolluxData&gt;) exchange.getIn().getBody();
  
          for (PolluxData value:stationsMasterList){
  
                     System.out.println(value.getStationCode() +","+value.getStationShortDescription());  
                     stationMap.put("id",value.getStationCode());
                     stationMap.put("ltr", value.getStationShortDescription());                  
  
          }
  
          return stationMap;
      }
  </code></pre>
  
  <hr>
  
  <p>sql.properties file is:</p>
  
  <pre><code>sql.insertNewRecord=INSERT INTO GSI_DEVL.POLLUX_DATA(STID,CLLTR) VALUES(:#id,#ltr)
  </code></pre>
  
  <hr>
  
  <p>Context.xml is </p>
  
  <pre><code>&lt;!-- configure the Camel SQL component to use the JDBC data source --&gt;
      &lt;bean id="sqlComponent" class="org.apache.camel.component.sql.SqlComponent"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  
      &lt;bean name="polluxDataController" id="polluxDataController" class="com.nielsen.polluxloadspring.controller.PolluxDataController" /&gt;
  
  
      &lt;camelContext trace="false" xmlns="http://camel.apache.org/schema/spring"&gt;
  
          &lt;!-- use Camel property placeholder loaded from the given file --&gt;
          &lt;propertyPlaceholder id="placeholder" location="classpath:sql.properties" /&gt;
  
          &lt;camel:route id="bindy-csv-marhalling-unmarshalling-exmaple" autoStartup="true"&gt;
                  &lt;camel:from uri="file://D://cameltest//input?noop=true&amp;amp;delay=10" /&gt;
  
                  &lt;camel:log message="CAMEL BINDY CSV MARSHALLING UNMARSHALLING EXAMPLE" loggingLevel="WARN"/&gt;
                  &lt;camel:unmarshal ref="bindyDataformat" &gt;
                      &lt;camel:bindy type="Csv"  classType="com.nielsen.polluxloadspring.model.PolluxData"  /&gt;
                  &lt;/camel:unmarshal&gt;
                  &lt;camel:log message="Station Details are ${body}" loggingLevel="WARN" /&gt;
  
                  &lt;camel:bean ref="polluxDataController" method="processPolluxData"  /&gt;
  
                  &lt;camel:log message="Station Details after bean process ${body}" loggingLevel="WARN" /&gt;
  
                  &lt;to uri="sqlComponent:{{sql.insertNewRecord}}" /&gt;
                  &lt;log message="Inserted new NewTopic ${body[id]}" /&gt;
                  &lt;log message="Inserted new NewTopic ${body[ltr]}" /&gt;
  
                  &lt;camel:log message="COMPLETED BINDY SIMPLE CSV EXAMPLE" loggingLevel="WARN" /&gt;
          &lt;/camel:route&gt;
  
      &lt;/camelContext&gt;    
  </code></pre>
  
  <p>Problem is this will insert only one row to database, but the file contains 2000 rows how can I acheive this</p>