Announcement Announcement Module
No announcement yet.
Bind variables usage in spring batch Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bind variables usage in spring batch

    Currently we are having place holders in sql, it is creating new sql id ever time in db.
    select * from customers where age >= '#{jobParameters['age']}'
    and to_number(cust_id) between '#{stepExecutionContext[minValue]}' and
    Please let me know how to use bind variables in spring batch.
    Last edited by mailtonbalaji; Sep 26th, 2012, 01:14 AM.

  • #2
    Do you mean binding input parameters into Spring wiring?

    <bean id="citySetter" class="com.xxxxxx.batch.mappers.preparedStatementS etters.CitySetter" scope="step">
    <property name="city" value="#{jobParameters[city]}"/>

    Could you clarify?



    • #3
      The values to this sql comes from job parameter. If i use as per your example it is creating new sqlid every time in the database. This is very costly. so avoid this issue we need to use bind variable some thing like this.

      <bean sql="select stud_id,stud_name from studentrecord where branch = :branch" />

      SqlParameterSource namedParameters = new MapSqlParameterSource(
      "branch", Branch);
      ParameterJdbcTemplate.queryForInt(sql, namedParameters);

      but i need some samples.
      Last edited by mailtonbalaji; Sep 27th, 2012, 01:33 PM.