Announcement Announcement Module
No announcement yet.
How to pass job parameters to job? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to pass job parameters to job?

    Hi all,

    I need to pass the value of jobe parameter to myJob.xml. With this parameter values my reader will run the dynamic sql query.
    But the value is not being retrieved. The value may be list of employee id as shown below.
    Can anyone tell me what am I missing? Also I am seeing the values are being replaced with "" (double quotes) which in my case shoud not work.
    Is there any way to trim it or to process it in other class?

    <beans:bean id="readDb" scope="step" class="org.springframework.batch.item.database.JdbcCursorItemReader">
    		<beans:property name="dataSource" ref="dataSource" />
    		<beans:property name="rowMapper">
    			<beans:bean class="com.test.EmployeeMapper" />
    		<beans:property name="sql">
    			<beans:value>select * from emp where empid in ?</beans:value>
    		<beans:property name="preparedStatementSetter" ref="statementSetter">
    	<beans:bean id="statementSetter" scope="step" 
    	<beans:property name="parameters">
    	<beans:value>"#{jobParameters['empid']}"</beans:value>				</beans:list>
    From the command line I am giving parameters as below:-

    java andLineJobRunner myJob.xml myJob empid=101,16,90
    I have also tried with java andLineJobRunner myJob.xml myJob empid='101,16,90'. But none of these works.

    Failed to initialize the reader......
    ...... nested exception is java.sql.SQLException: ORA-01722: invalid number
    One more question is can I manipulate the values in between command line and reader so that the manipulated value ultimately goes as input in reader sql's input parameter.
    Please help.
    Last edited by kousik.majumder; Nov 27th, 2010, 05:45 AM.

  • #2
    You JdbcCursorItemReader has to be scope="step" to make the late binding work. I didn't understand the second question - did you need a JobParametersConverter?