I try to query my Mysql DB using JDBC.
I use the org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations
.
The column DATE_FROM
in my_table
is defined as DATE
column (which is also a PK).
A simplified version of a query which works looks like this:
SELECT * FROM my_table WHERE DATE_FROM >='2015-03-01';
But then, I tried to change the the '2015-03-01' to be given as a named parameter. the query looked like this:
SELECT * FROM my_table WHERE DATE_FROM >=:fromDate;
while I invoked the NamedParameterJdbcOperations.update()
like this:
map.put("fromTime", '2015-03-01');
namedParameterJdbcOperations.update(sql, map);
Although everything, to my understanding, remains the same, I get:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect date value: ''2015-03-01'' for column 'MEASUREMENT_DATE' at row 1.
Does someone know why?