1

I Have the query similar to this one :

sql :

select count("A"),"B","C" from schema."xxx" where  "TIME"<? and "TIME">=? AND "C"='mmn' group by "B","C" 
union  
select count("A"),"B","C" from schema."xxx" where  "TIME"<? and "TIME">=? AND "C"='nno' group by "B","C" order by "C" 

and I am using a

getJdbctemplate.query(sql,new Object[startTime,EndTime],Rowmapper) 

I am not sure if this is not the correct way to pass the arguments cause when I try to do this it is erroring out wrt an incorrect number of parameters passed.

Jasurbek
  • 2,946
  • 3
  • 20
  • 37
Htijihba
  • 11
  • 3

1 Answers1

0

You need to replace 4 ? placholders

 getJdbctemplate.query(sql,new Object[startTime,EndTime , startTime,EndTime ],Rowmapper) 

Also it seems that you should start with endDate

If you used NamedParameterJdbcTemplate you could use 2 placeholders as :startDate and :endDate

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
  • Thanks for the response!, This I am doing in the old code which was written by someone else and if I change it to NamedParameterJdbcTemplate I would need to change for all the other methods as well, also if i have it exclusively for this one then there will be 2 instances of jdbc templates. please correct me if I am wrong. – Htijihba Jul 04 '19 at 06:28
  • Also i have tried doing this getJdbctemplate.query(sql,new Object[startTime,EndTime , startTime,EndTime ],Rowmapper) its still the same result – Htijihba Jul 04 '19 at 06:29