I’m trying to query data from HSQLDB 2.2.8 with Spring JDBC 3.1.2.RELEASE, here’s the statement:
"SELECT id, account_id, operator_id, amount, currency_type, date
FROM account_entries WHERE account_id=? AND date BETWEEN DATE '?' AND DATE '?' + 1 DAY"
Properties are:
1 (java.lang.Integer)
2012-09-06 (java.sql.Date)
2012-09-06 (java.sql.Date)
The error I receive:
PreparedStatementCallback; SQL [SELECT id, account_id, operator_id, amount,
currency_type, date FROM account_entries WHERE account_id=?
AND date BETWEEN DATE '?' AND DATE '?' + 1 DAY]; data exception:
invalid datetime format; nested exception is java.sql.SQLDataException:
data exception: invalid datetime format
You must either drop the date casts:
... date BETWEEN ? AND ? + 1 DAY ...or keep them, but pass the parameters as correctly formatted strings (YYYY-MM-DD) instead of java.sql.Date objects.