Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8670437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:42:27+00:00 2026-06-12T18:42:27+00:00

I have a job that has to run multiple times with different job parameters.

  • 0

I have a job that has to run multiple times with different job parameters. I want to set up a JdbcCursorItemReader to perform a query for the job, the itemReader is configured like this:

<bean id="tpsItemReader" 
    class="org.springframework.batch.item.database.JdbcCursorItemReader">
    <property name="dataSource" ref="myDataSource"/>
    <property name="sql" value="#{sqlQueries['tps.findStuffforSomeSubset']}"/>
    <property name="preparedStatementSetter">
        <bean class="com.initech.reports.tps.ParameterSetter">
            <!-- can't hardcode this, I want a job parameter here -->
            <constructor-arg value="A"/> 
        </bean>
    </property>
    <property name="rowMapper">
        <bean class="com.initech.reports.tps.CustomerRowMapper"/>
    </property>
</bean>

and the job is configured like this:

<batch:job id="tpsReportJob">
    <batch:step id="tpsReportJob.generateReport">
        <batch:tasklet>
            <batch:chunk reader="tpsItemReader" 
            processor="tpsItemProcessor" 
            writer="tpsItemWriter" commit-interval="100000"/>
        </batch:tasklet>
    </batch:step>
</batch:job>

The parameterSetter is pretty minimal:

package com.initech.reports.tps;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.springframework.jdbc.core.PreparedStatementSetter;

public class ParameterSetter implements PreparedStatementSetter {

    private final String x;

    public ParameterSetter(String x) {this.x = x;}

    @Override
    public void setValues(PreparedStatement ps) throws SQLException {
        ps.setString(1, x);
    }
}

This is using spring-batch 2.1.8.

How do I get the job parameter into the query?

I think I’m close, I tried changing the parameter setter config to:

        <bean class="com.initech.reports.tps.ParameterSetter">
            <constructor-arg value="#{jobParameters['myParam']}"/>
        </bean>

but I get this error:

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'jobParameters' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:208)
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:72)
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:52)
    at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:88)
    at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:139)
    ... 51 more

I found a very similar question, the difference between that one and this is that I don’t have a reader class to annotate, I just have the xml entry because I’d like to avoid having to create my own itemReader. (I could try overriding the jdbcCursorItemReader class just to be able to annotate it…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:42:29+00:00Added an answer on June 12, 2026 at 6:42 pm

    All it took was adding the scope attribute onto the parameterSetter class:

        <bean class="com.initech.reports.tps.ParameterSetter"
            scope="step">
            <constructor-arg value="#{jobParameters['myParam']}"/>
        </bean>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Agent Job that has multiple steps which are scheduled to
I have a job that must execute each monday. This job run in a
If I have a cron job that run every 10 minutes and for some
I have a daily cron job that email PDFs to customers. I want to
I have a CRON job php script that I just set up not too
I have a timer job which has been deployed to a server with multiple
Using EF Code First I have an model object that has multiple properties that
I have an app that has a BG module which is forced to run
I have a DGV that has its datasource set to a BindingList. There is
Introduction I have a app that has multiple tables, some with and some without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.