Results 1 to 3 of 3

Thread: Bind variables usage in spring batch

Hybrid View

  1. #1

    Default Bind variables usage in spring batch

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

  2. #2

    Default

    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]}"/>
    </bean>

    Could you clarify?

    Jeff

  3. #3

    Default

    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 at 01:33 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •