0

I need to execute a query using spring jdbctemplate.

@Autowired
JdbcTemplate jdbcTemplate;

jdbcTemplate.query("select * from my_table where member_id = ? and start_date in (?)", new Object[]{10, Arrays.asList(new Date()), myRowMapper)

But i got this error:

SQLWarning ignored: SQL state '22007', error code '1292', message [Truncated incorrect datetime value: '\xAC\xED\x00\x05sr\x00\x13java.util.ArrayListx\x81\xD2\x1D\x99\xC7a\x9D\x03\x00\x01I\x00\x04si 

I tried to change Date into java.sql.DateTime() but it still doesn't work. How can I make spring understand to format date correctly?

Sean Nguyen
  • 12,528
  • 22
  • 74
  • 113
  • try this https://stackoverflow.com/a/1327222/11733759 – lczapski Feb 03 '20 at 06:18
  • It isn't due to the `Date` but the fact you are using in, with a single question mark and passing in a list. Just put a single `Date` in there, not a list. If you need multiple arguments, you also need multiple placeholders (and not a list either). – M. Deinum Feb 03 '20 at 06:40

0 Answers0