-
Jun 11th, 2013, 03:13 PM
#1
Date parameter to JobParameters to the sql provided in JdbcCursorItemReader
I have a simple batch job, that need to take date as an input parameter for the sql in JdbcCursorItemReader
When I make it to take input from Job parameters, it gives the error
ORA-01858: a non-numeric character was found where a numeric was expected
; nested exception is java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
[CODE]
<bean id="fetchDataDao"
class="org.springframework.batch.item.database.Jdb cCursorItemReader">
<property name="dataSource" ref="dataSource" />
<property name="sql">
<value>
<![CDATA[
(select * from table1
WHERE
enddate >= to_date(?,'DD-Mon-YYYY')
)
]]>
</value>
</property>
<property name="preparedStatementSetter">
<bean class="org.springframework.batch.core.resource.Lis tPreparedStatementSetter">
<property name="parameters">
<list>
<value>#{jobParameters[endDate]}</value>
</list>
</property>
</bean>
</property>
JobLauncher launcher = (JobLauncher) context.getBean("jobLauncher");
Job job = (Job) context.getBean("simpleJob");
JobParametersBuilder builder = new JobParametersBuilder();
Date endDate = new Date("31-May-2013");
builder.addDate("endDate", endDate);
JobParameters parameters = builder.toJobParameters();
try{
launcher.run(job, parameters);
}catch(......
......
..
When I hard code the date value for the above sql in the JdbcCursorItemReader, it works fine.
select * from table1 where enddate >= to_date('31-May-2013','DD-Mon-YYYY')
[CODE]
Please suggest
-
Did you try by removing the to_date in sql?
select * from table1 WHERE enddate >= ?
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
-
Forum Rules