I want to execute a query using 2 date job parameters which are late binding with spring batch.
JobParametersBuilder Builder = New JobParametersBuilder () builder.addDate ("Until", unless); Builder.edit ("Start", Start); JobExecution Exec = jobLauncher.run (myJob, builder.toJobParameters ())
My bean / job definition:
myReader (JdbcPagingItemReader) {Same - & Gt; Bean.scope = 'step' bean.autowire = 'byname' data source = referee ('data source') queryProvider = ref ('sqlPagingQueryProviderFactoryBean') parameterValues = [start: "# {jobParameters ['start']}" , Unless: "# {jobParameters ['until']}"] pageSize = '10' rowMapper = ref ('myRowMapper') // did not show here} sqlPagingQueryProviderFactoryBean (sqlPagingQueryProviderFactoryBean) {sub -> Bean.autowire = 'byname' bean.scope = 'step' data source = ref ('data source') selectClause = 'some_timestamp, column 2' fromClause = 'some_table' whereClause = 'some_timestamp & gt; = Dali (Started as Timestamp) and some_timestamp & lt; (Such as a timestamp) 'Sort of =' some_timemstamp '}
I am getting all kinds of errors, depending on how I should insert timestamps etc. Code):
step.AbstractStep has failed to perform a task in MyStep for myJob org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; Select some [some_timestamp, some some_table from some_table table = some_timestamp> = cast (? Timestamp) and some_timestamp & lt; Some_timestamp ASC limit by CAST (? Timestamp) by ORDER 10]; Error: Invalid input syntax for typed timestamp: "# {Job parameter ['Start']}"; Error: Invalid input synthesis for type timestamp: nested exception is org.postgresql.util.PSQLException error :: invalid input syntax for type timestamp "# {jobParameters ['start']}" nested exception org.postgresql Use.PSQLException is: "# {JobPameters ['Start']}"
How do I use the timestamp for my query?
Instead of using just binding here.
// within myReader, no need for parameters / parameterValues = [// start: "# {jobParameters ['start']} ", // until:" # {jobParameters ['till']} "// // // within sqlPagingQueryProviderFactoryBean whereClause =" some_timestamp " = '# {JobParameters [\' start \ ']}' :: timestamptz and some_timestamp & lt; ' # {JobParameters [\ 'as long as \']} :: timestamp: "
No comments:
Post a Comment