java - How to send List of dates as part of sql query using SpringTemplate + JDBCTemplate -


well, have query :

select * table somedate in (date1, date2, date3); 

i trying construct using st (springtemplate) , using jdbctemplate make query.

if have pass 1 date, can use :

stringtemplateinstance.add("somecolkey",dateinstance); 

but how can send list of dates in clause gets it?.

right now, using stringutils.collectiontocommadelimitedstring(datelistforquery); query ( don't like).

ditch both stringtemplate jdbctemplate , switch namedparameterjdbctemplate.

string query = "select * table somedate in (:dates)"; map<string, object> params = new hashmap<string, object>(); params.put("dates", yourlistofdates);  list<yourresulttype> result = template.query(query, params, new yourresulttyperowmapper()); 

that all.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -