0

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?

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
user1028741
  • 2,745
  • 6
  • 34
  • 68

1 Answers1

0

Did you realize that you named the placeholder in the SQL "fromDate" and in the map, you named it "fromTime"?

El Abogato
  • 123
  • 1
  • 5